且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MSBuild:指定用于子版本的平台时出现问题

更新时间:2023-02-17 12:47:07

AgentProjectFiles 项的声明中,您定义 Properties 元数据.看起来是这样的吗?

<ItemGroup>
    <AgentProjectFiles Include="something.proj">
        <Properties>SOME VALUES HERE</Properties>
    </AgentProjectFiles>
</ItemGroup>

如果已定义该属性,则将属性传递到 MSBuild任务将被忽略.我已经通过博客发布了有关 MSBuild:已知的元数据和属性.. >

易卜拉欣·哈希米说

我的书:在Microsoft Build Engine内部:使用MSBuild和团队基础建设

Is it possible to specify the target platform (x64, x86) when building a project?

I have a build task that looks as follows:

<MSBuild Projects="%(AgentProjectFiles.FullPath)" Properties="Architecture=x86;Configuration=$(Configuration);Optimize=$(Optimize);Platform=$(Platform);OutputPath=$(OutputDirectory)\Agent\;ReferencePath=$(ReferencePath);DebugSymbols=$(DebugSymbols);DebugType=none;" />

As you can probably tell, I've thrown everything possible I have seen online into the Properties attribute in the hope that it will work. You will notice that for the Architecture property I've set it to be x86 explicitly. the $(Platform) is also set to x86. I've tried a number of permutations, without success.

Unfortunately, it seems that no matter what gets put into these properties, my class libraries are x86, but my executables are x64.

I thought perhaps the problem could be that the build properties specified in the project file itself were causing MSBuild to ignore the ones I pass through from MSBuild, but after changing these to x86, I still have the same problem.

Any ideas?

In the declaration of the AgentProjectFiles item are you defining the Properties metadata. So does it look like:

<ItemGroup>
    <AgentProjectFiles Include="something.proj">
        <Properties>SOME VALUES HERE</Properties>
    </AgentProjectFiles>
</ItemGroup>

If you have defined that then the properties passed into the Properties attribute of the MSBuild task are ignored. I've bloged about this MSBuild: Properties and AdditionalProperties Known Metadata.

Sayed Ibrahim Hashimi

My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build