1

In all of the component projects of my C# solution, "Platform target" is set x64 in Project>Properties>Build. However, the Platform property is still "Active (Any CPU") and that is the only option. In the build log, I can see that it is copying both x64 and x86 versions of some nuget packages. Two questions:

  • If I've specified why x64, why is it still copying x86 packages?
  • Is there way to eliminate "Any CPU" as a platform option and ONLY build x64?
Kevin McDowell
  • 532
  • 6
  • 20

1 Answers1

2

The Platform target under Project>Properties>Build is not the right option for your build process. That option is to tell which platform the project assembly is compiled for rather than your nuget package. So, the option cannot change the build platform and your nuget package still uses the build platform to judge which version of the dll is copied into the main project output folder.

More info you can refer to this document.

Suggestion

You can use Configuration Manager under Build

enter image description here

enter image description here

You should locate your Project and then choose x64 to build your Project Platform. And if you did not have x64, you have to click New to create it.

Update 1

Your Build Configuration is in a mess. So please first enter each project Properties-->Build--> change Platform target to Any CPU to do a restore operation.

Then, enter your Configuration Manager, delete any x64 and x86 platform under Active Solution Platform and Project Platform if you have. Then, click Active Solution Platform and then create a new x64 platform.

This will set uniform platform settings for each project.

You can refer to this similar issue.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Been there. The Active Solution Platform is x64. But each of the projects is listed as "Any CPU". When I click the drop-down, x64 is not an option. When I click New and try to add x64, I get this error: "This platform could not be created because a solution platform of the same name already exists". Individually, each platform has its property in the csproj file set to x64 also. Additionally, we never want it to build x86. We are deploying to Azure and all the host machines are 64-bit, so there's no need for Any CPU. – Kevin McDowell Jan 26 '21 at 17:23
  • 1
    Your Build Configuration is in a mess. So please first enter each project Properties-->Build--> change `Platform target` to `Any CPU` to do a restore operation. Then, enter your `Configuration Manager`, delete any `x64` and `x86` platform under `Active Solution Platform` and `Project Platform` if you have. Then, click `Active Solution Platform` and then create a new `x64` platform. This will set uniform platform settings for each project. – Mr Qian Jan 27 '21 at 08:38
  • 1
    I have updated my answer and you can check it. – Mr Qian Jan 27 '21 at 08:38