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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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 <PlatformTarget> 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.
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.
I have updated my answer and you can check it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.