我想在项目的同时构建2个配置 . 让's say that when I want to build the Release I want to build even the Debug (the opposite isn' t为真) . 从Use a single Visual Studio solution to build both x86 and x64 at the same time?开始,我尝试添加到.csproj
<Target Name="AfterBuild">
<MSBuild Condition=" '$(Configuration)' == 'Release' " Projects="$(MSBuildProjectFile)" Properties="Configuration=Debug" RunEachTargetSeparately="true" />
</Target>
如果我尝试通过MSBuild构建项目
MSBuild ConsoleApplication64.csproj /p:Configuration=Release /p:Platform=x86
它工作正常 . 两个配置都正确构建,一切都很好 .
问题是,如果我尝试使用Visual Studio构建它:版本正确构建,然后它开始构建调试版本,它给了我
将文件从“obj \ x86 \ Debug \ ConsoleApplication64.exe”复制到“bin \ Debug \ ConsoleApplication64.c:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ Microsoft.Common.targets(2868,9):error MSB3021:无法将文件“obj \ x86 \ Debug \ ConsoleApplication64.exe”复制到“bin \ Debug \ ConsoleApplication64.exe” . 找不到文件'obj \ x86 \ Debug \ ConsoleApplication64.exe' .
前提条件:
Windows XP SP3 ITA,Visual Studio 2010 SP1英文版,该项目是一个空的C#4.0控制台应用程序(技术上它不是,但我可以重现这个问题) .
(请注意,为了让这些消息我已经激活了详细程度:正常来自工具 - >选项 - >项目和解决方案 - >构建和运行 - > MSBuild项目构建输出详细程度 .
在比较两个“半”运行的输出之后,不同之处在于,在“工作”一半中调用csc,而另一个则不是:
发布一半:
任务“Csc”(TaskId:13)c:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ Csc.exe / noconfig / nowarn:1701,1702 / nostdlib / platform:x86 / errorreport:prompt / warn:4 / define:TRACE / reference:“C:\ Programmi \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ Microsoft.CSharp.dll”/ reference:“C:\ Programmi \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ mscorlib.dll“/ reference:”C:\ Programmi \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ System.Core.dll“/ reference :“C:\ Programmi \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ System.dll”/ debug:pdbonly / filealign:512 / optimize /out:obj\x86\Release\ConsoleApplication64.exe / target:exe Program.cs Properties \ AssemblyInfo.cs“C:\ Documents and Settings \ m.alberti-cons \ Impostazioni locali \ Temp.NETFramework,Version = v4.0,Profile = Client.AssemblyAttributes.cs”(TaskId: 13)完成执行任务“Csc” . (TASKID:13)
调试一半:
任务“Csc”(TaskId:41)完成执行任务“Csc” . (TASKID:41)
经过一些更多的测试,我注意到如果两半使用相同的 DefineConstants
那么就没有了.1858205_ t工作 . :-(
1 回答
您可以跳过标记为已运行的目标的机制.188206_ s incremental build . 这里真正的问题是如何打破这种增量构建 . This问题非常相关 .
如果使用
/verbosity=diag
构建,您会注意到MSBuild报告了一堆这些:微软意识到这种行为并考虑到这一点by design .
我强烈建议的一种可能的解决方法是使用Exec任务调用第二个构建 . Exec任务只是一个命令行shell,它会吃掉你要用它提供的所有东西,但在你的情况下,它可以打破增量构建链 .