Task execute well with Msbuild but not in visual studio
I get a strange behaviour in visual studio Vs executing msbuild in command line.
a solution (s1) contains 3 project (p1,p2,pB). p1 and p2 are "normal" VS project while pb is an xml msbuild file I wrote myself. The purpose of the task pB contains is modifying some part of the source code.
I did configure dependencies so that p1 and P2 depends on pB to be sure pB is the first project to execute.
When a do a compilation (pressing F6 key) in visual studio, the files are modified but it seems 开发者_开发知识库that p1 and p2 start before that modification so my result is not what I expended. Also, when I look in the build console everything seems ok.
And when A launch the compilation via "msBuild s1", everything is perfected !
How can I have the same behaviour between VS2010 and msbuild ?
Thx
Everytime you build a VS solution it creates a .sln.cache file wich is a quite a csproj file with every project you have in your solution.
Thus modifying the csproj files during the build will have no effect in your current build (which uses the .sln.cache file).
If you register pB project in BeforeBuild in both projects p1 and p2 like
<Target Name="BeforeBuild">
<MSBuild Projects="pB.proj" Properties="Configuration=$(Configuration)" />
</Target>
you can call MSBuild task and pass all needed parameters. This solution will works in both environments.
精彩评论