Build doesn't work from VisualStudio, but is o

2020-05-01 20:30发布

From a brand new console application template in visual studio, I edited the .csproj to build another project like this:

...
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
  <MSBuild Projects=".\other.mproj"/>
</Target>    
...

Where other.mproj is:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">

   <Target Name="Build">
       <Message Text="kikou" />     
   </Target>

</Project>

After a while I discovered that modifying the content of other.mproj (for instance, by introducing errors or changing text kikou to something else) would not be taken into account unless unloading/reloading the project in visual studio.

Building from the command line with 'msbuild myproj.csproj' immediatly detect changes in 'other.mproj'. So it all looks like visual studio is working from a cached version of other.mproj file.

Why is visual studio caching this other script (which is even not included to the project), and how can I solve this issue ?

Update: I also tried this UseHostCompilerIfAvailable, it doesn't work.


NB1: I didn't add other.mproj as a project reference in the .csproj because it is not a .NET project at all (it just creates resources files for the .csproj from other inputs before the build)

NB2: I'm using VS2010 (10.0.10219.1SP1Rel + MSBuild 4.0.30319.1)

1条回答
混吃等死
2楼-- · 2020-05-01 21:09

Visual Studio caches all MSBuild files, this is done for performance reasons. You will not be able to have an MSBuild only way around this. It may be possible to achieve this via a VS add-in but I'm not 100% sure of that.

查看更多
登录 后发表回答