3

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?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
tardomatic
  • 2,396
  • 3
  • 21
  • 29

1 Answers1

3

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

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
  • 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 Jul 16 '09 at 18:13
  • I don't really believe this is the truth. Thank you Sayed. – Pete Montgomery Mar 29 '10 at 17:37