繁体   English   中英

使用msbuild.exe生成C#项目不会覆盖项目目标平台配置吗?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM