MSBuild task adding file to project and generating warning.
Just added the the MSBuild task to a new project, and ran it with a simple test script (just outputs "//Hello?"). It all works fine, except the file was unexpectedly added to the project. I don't really mind that, since it's nice to be able to see the output more easily, but it also resulted in the warning "Source file 'Test.cs' specified multiple times."
Setting Output.BuildAction = BuildAction.None makes it go away, as does setting the file's Build Action to None in visual studio, so not a big deal, but it'd be nice if the default behavior didn't create warnings without additional manual steps.
Also, I am not clear on what the final behavior would be setting the action in the script, worried it might end up compiling the previous version of the output.
Edit: Upon further testing, setting the build action in visual studio seems to prevent the output being compiled at all, regardless of how it's set in the script. However, setting it to None in script and leaving it alone in VS definitely seems to do the final build with the latest output. So I guess that's the workaround.
This is probably related to #34. Do you also have the Visual Studio addin installed? I agree there shouldn't be a warning during normal usage.
I do, tho it didn't apply to that particular project (.NET Standard). Don't know if that would impact the odds of it being related or not.
I am seeing the same thing, and I've never had the VS add-in installed. Just running with the MSBuild NuGet package, I'm getting this warning all the time.
@MelGrubb The issue here is that the Scripty MSBuild task adds the output file from the script to the compilation by default (though this can be controlled in your script). If the output file is also included either explicitly in legacy csproj files or implicitly via wildcards in the new SDK csproj style projects, it ends up in the list of files to compile twice.
The next version of Scripty (no timeline at the moment, but there will be a next version at some point when I get back to it), this should be resolved because I'm pretty sure I'm going to render the script output files to the obj directory. In the meantime, you can set the build action to None for the output file from within your script: Output.BuildAction = BuildAction.None;. That'll prevent the Script MSBuild task from adding it to the compilation if it's already been included from the project file.
Thanks. Adding the Output.BuildAction made it go away for now.
Unfortunately, I’m having a different problem now. Please tell me if this sounds at all familiar. As soon as I start trying to add AspNet Identity components to my solution, or more specifically as soon as I try to make my User object inherit from IdentityUser, I start getting errors like this from the build.
Severity Code Description Project File Line Suppression State Error System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Identity.Stores, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified. Foo.Builders C:\Users\Mel.nuget\packages\scripty.msbuild\0.7.4\build\Scripty.MsBuild.targets 31
I’ve tried adding a NuGet package reference to Microsoft.Extensions.Identity.Stores to the Data project as well as to the project that has the .csx script in it. It makes no difference. Hopefully this has come up at some point in the past and has a simple solution… just not one that google is helping me find efficiently at the moment.
From: Dave Glick [email protected] Sent: Wednesday, August 15, 2018 8:39:39 AM To: daveaglick/Scripty Cc: Mel Grubb; Mention Subject: Re: [daveaglick/Scripty] MSBuild task adding file to project and generating warning. (#90)
@MelGrubbhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMelGrubb&data=02%7C01%7C%7C3f436a23ae9e484eca3b08d602ac2b97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636699335816111367&sdata=uoH1Y4eRK%2FnJaaobuWKSadzmAlGxoMpa%2F7p3meI5P%2Fk%3D&reserved=0 The issue here is that the Script MSBuild task adds the output file from the script to the compilation by default (though this can be controlled in your script). If the output file is also included either explicitly in legacy csproj files or implicitly via wildcards in the new SDK csproj style projects, it ends up in the list of files to compile twice.
The next version of Scripty (no timeline at the moment, but there will be a next version at some point when I get back to it), this should be resolved because I'm pretty sure I'm going to render the script output files to the obj directory. In the meantime, you can set the build action to None for the output file from within your script: Output.BuildAction = BuildAction.None;. That'll prevent the Script MSBuild task from adding it to the compilation if it's already been included from the project file.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdaveaglick%2FScripty%2Fissues%2F90%23issuecomment-413185229&data=02%7C01%7C%7C3f436a23ae9e484eca3b08d602ac2b97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636699335816111367&sdata=Rw9iuI1%2FvRn4ButBEBuFs9v5TYZwzr8ifsWmwAatZuI%3D&reserved=0, or mute the threadhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABGZB0WjiWX7pu_6l6_TqKNitjwb7QZfks5uRBaLgaJpZM4M5ofT&data=02%7C01%7C%7C3f436a23ae9e484eca3b08d602ac2b97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636699335816111367&sdata=aGATsJ1nvQ0k7vWDDDotEoujoCqLaBY0i6p3SDbYaAk%3D&reserved=0.