I have a csproj file which references a shared MSBuild script with an <Import>
directive. I have noticed that when I change the shared script, I need to close and reopen Visual Studio before it notices the change - a build within Visual Studio notices changes to the csproj file but not the shared file.
This doesn't happen when I build the project with MSBuild from the command line. Is Visual Studio caching the imported script? If so, why? And how can I turn off this behaviour which makes authoring build scripts hard / impossible using Visual Studio?
Thanks!
Instead of closing and re-opening Visual Studio have you tried, unloading and reloading the project (.csproj) which imports the shared script? You can do this from the Solution Explorer in Visual Stduio by right clicking on the loaded project and selecting unload and then on the unloaded project and picking load.
In my experience, Visual Studio 2015 behaves better than Visual Studio 2008. VS picks up changes from imported files in most cases, at least for C# projects. YMMV for other project types, though.
While the solution explorer doesn't reflect changes, the build uses the updated version of the import file.
So, the solution may be to use a more recent version of Visual Studio.