MSBuild 任务配置属性
我有三个 Visual Studio 解决方案。 第一个配置为构建为发布,另外两个设置为构建为调试。
当运行一个简单的 MSBuild 脚本并明确说明要构建的配置(调试)时,第一个项目是仍然构建为发布版本。
示例脚本:
<Target Name="Build">
<ItemGroup>
<ProjectToBuild Include="$(SolutionsPath)\Solution1.sln"/>
<ProjectToBuild Include="$(SolutionsPath)\Core\Solution2.sln"/>
<ProjectToBuild Include="$(SolutionsPath)\UI\Solution3.sln"/>
</ItemGroup>
<MSBuild Projects="@(ProjectToBuild)"
Targets="Rebuild"
Properties="Configuration=Debug;Platform=Any CPU"/>
</Target>
我尝试了上述的变体,如下所示,但我总是得到相同的结果。
<Target Name="Build">
<ItemGroup>
<ProjectToBuild Include="$(SolutionsPath)\Solution1.sln">
<Properties>Configuration=Debug</Properties>
</ProjectToBuild>
<ProjectToBuild Include="$(SolutionsPath)\Core\Solution2.sln">
<Properties>Configuration=Debug</Properties>
</ProjectToBuild>
<ProjectToBuild Include="$(SolutionsPath)\UI\Solution3.sln">
<Properties>Configuration=Debug</Properties>
</ProjectToBuild>
</ItemGroup>
<MSBuild Projects="@(ProjectToBuild)"
Targets="Rebuild"
Properties="Platform=Any CPU"/>
</Target>
我注意到有一个类似的问题,MSBuild 任务 - 构建失败,因为在版本中构建了一个解决方案而不是调试,但这特定于 TFS 和 Teambuild。 我说的是纯 MSBuild,带有一个从头开始创建的简单项目文件。
我该如何解决这个问题?
I have three Visual Studio solutions. The first is configured to build as Release, and the other two are set to build as Debug.
When running a simple MSBuild script explicitly stating the configuration to build (Debug), the first project is still built as Release.
Sample script:
<Target Name="Build">
<ItemGroup>
<ProjectToBuild Include="$(SolutionsPath)\Solution1.sln"/>
<ProjectToBuild Include="$(SolutionsPath)\Core\Solution2.sln"/>
<ProjectToBuild Include="$(SolutionsPath)\UI\Solution3.sln"/>
</ItemGroup>
<MSBuild Projects="@(ProjectToBuild)"
Targets="Rebuild"
Properties="Configuration=Debug;Platform=Any CPU"/>
</Target>
I have tried variations of the above such as the following, but I always end up with the same result.
<Target Name="Build">
<ItemGroup>
<ProjectToBuild Include="$(SolutionsPath)\Solution1.sln">
<Properties>Configuration=Debug</Properties>
</ProjectToBuild>
<ProjectToBuild Include="$(SolutionsPath)\Core\Solution2.sln">
<Properties>Configuration=Debug</Properties>
</ProjectToBuild>
<ProjectToBuild Include="$(SolutionsPath)\UI\Solution3.sln">
<Properties>Configuration=Debug</Properties>
</ProjectToBuild>
</ItemGroup>
<MSBuild Projects="@(ProjectToBuild)"
Targets="Rebuild"
Properties="Platform=Any CPU"/>
</Target>
I note there is a similar question, MSBuild task - Build fails because one solution being built in release instead of debug, but that is specific to TFS and Teambuild. I am talking pure MSBuild with a simple project file created from scratch.
How can I fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
关于任何 cpu 平台的拼写问题,事实证明存在一个问题,该问题已在 StackOverflow 和 Microsoft 的其他地方报告过。 它通常会影响 MSBuild,并且我的 dotnet v3.5 MSBuild /help 中省略了整个
Platform
文档问题。 所以也许这会对某人有所帮助!链接
TFS 2010 中的“任何 CPU”与“任何 CPU”
解决方案和项目之间的“任何 CPU”的 MSBuild 平台不一致
MSBuild
Platform
属性具有不同的值 strong> 适用于任何 CPU
,具体取决于您是构建解决方案还是构建项目。- 对于解决方案 - 使用
Platform="Any CPU"
- 带空格- 对于项目 - 使用
Platform="AnyCPU"
- 没有空间Regarding the question of spelling of platform any cpu, it turns out there is an issue, already reported elsewhere here on StackOverflow and Microsoft. It affects MSBuild in general and the entire issue of
Platform
documentation is omitted in my dotnet v3.5 MSBuild /help. So perhaps this will help someone!Links
"AnyCPU" vs "Any CPU" in TFS 2010
MSBuild inconsistent platform for "Any CPU" between solution and project
The MSBuild
Platform
property has a different value forAny CPU
depending upon whether you are building a solution or building a project.- for Solution - use
Platform="Any CPU"
- with space- for Project - use
Platform="AnyCPU"
- without space好的,我已经找到问题了。 与 MSBuild 无关,而是正在构建的解决方案。 发帖是为了挽救别人的心痛。
无论出于何种原因,在解决方案中配置调试配置如下:
alt text http://www.freeimagehosting.net/uploads/ cad0bdf1c0.jpg
所以 MSBuild 也只是按照它的指示去做......
OK I have found the issue. Nothing related to MSBuild, but instead the solution being built. Posting to save someone else the heartache.
For whatever reason the Debug configuration was configured within the solution like so:
alt text http://www.freeimagehosting.net/uploads/cad0bdf1c0.jpg
So MSBuild was only doing what it was told too...
我遇到了同样的错误。 解决方案是明确指定目标平台:
自从我升级到 Windows 7 以来,这种情况才开始发生,所以我想这与此有关。
I was getting this same error. The solution was to explicitly specify the target platform with:
This only started happening since I upgraded to windows 7, so I guess it is something to do with that.
您是否尝试过使用 /v:diag 运行?
另外,顺便说一句:我认为你想要“AnyCPU”(没有空间)。
Have you tried running with /v:diag?
Also, aside: I think you want "AnyCPU" (no space).