How to stop Visual Studio caching Imported MSBuild

2019-07-04 06:03发布

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!

2条回答
不美不萌又怎样
2楼-- · 2019-07-04 06:43

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.

查看更多
别忘想泡老子
3楼-- · 2019-07-04 06:48

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.

查看更多
登录 后发表回答