![](/img/trans.png)
[英]Using msbuild.exe to build a project with a dependency requiring a different Platform property
[英]Build C# project with msbuild.exe doesn't overwrite project target platform configuration?
我有一個ac#項目,在解決方案中,平台目標是AnyCPU。 雖然我有一個生成程序,它將每天生成此解決方案,並且它使用msbuild.exe。 該命令喜歡:
MSBuild D:\\ my.sln / p:Configuration =發布/ p:Platform = x86 / t:rebuild ....
在這里,我指定編譯平台應為x86。
我認為,msbuild.exe應該覆蓋解決方案配置,並且輸出應該是x86 exe而不是anyCPU類型。
我將這些代碼嘗試到該項目中:
PortableExecutableKinds peKind;
ImageFileMachine machine;
Assembly.GetExecutingAssembly().ManifestModule.GetPEKind(out peKind, out machine);
測試結果表明,exe是AnyCPU模式(ILOnly),而不是預期的。 在這種情況下,我如何通過代碼知道我的程序是x86還是x64編譯器?
謝謝。 里
我更喜歡不構建.sln文件,而是使用帶有一點構建腳本的msbuild.exe
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="BuildProjects" >
<ItemGroup>
<BuildProjectsInputFiles Include="**\MainProject\*.??proj" />
<BuildProjectsInputFiles Include="**\AnotherProject\*.??proj" />
</ItemGroup>
<MSBuild Projects="@(BuildProjectsInputFiles)" Properties="Configuration=$(Configuration);OutputPath=$(MSBuildProjectDirectory)\Deploy\bin\%(BuildProjectsInputFiles.FileName)">
<Output TaskParameter="TargetOutputs"
ItemName="BuildProjectsOutputFiles" />
</MSBuild>
</Target>
</Project>
現在,我在此調用中使用msbuild
msbuild.exe build.xml /p:OutputPath=bin\Debug;Configuration=Release;Platform=x86 /target:BuildProjects
那行得通
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.