tags:

views:

1629

answers:

1

Hi,

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?

Thanks in advance.

+2  A: 

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
THANK YOU!!!(excuse the caps, but ive been hitting my head against the wall for a few hours with this.)I changed my ItemGroup to define the properties as you have above, and my assemblies are now being created for the correct platform.
tardomatic
I don't really believe this is the truth. Thank you Sayed.
Pete Montgomery