Is there a way to force msbuild to only build x64? - visual-studio

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?

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
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.

Related

Visual Stodio - compiling project for 32-bit or 64-bit system

When I compile some kind of a project in Visual Studio 2015, does it compile it for 32-bit or 64-bit systems? Is there any way to find out? How do I control which version it compiles between the two?
From the menu bar, you can see the current platform for which the project will be compiled.
If you press the little arrow, you can open the Configuration Manager and create new target platforms.
The Configuration Manager is also available under Build ---> Configuration Manager.

Wix installer project build skipped in Any CPU solution

I'm trying to build a solution that is configured as Release | Any CPU that contains a Wix installer project which is configured for x86. Everything in the solution is built fine but Wix installer is always skipped.
It works fine building in visual studio but from the command line there are issues.
I'm calling it like so:
"C:/Program Files (x86)//Microsoft Visual Studio 10.0/Common7/IDE/devenv.com" /Rebuild "Release|Any CPU" "MySolution.sln"
And this is the error
Skipped Rebuild All: Project: Service.WixInstall, Configuration: Release x86 ----- Project not selected to build for this solution configuration
This isn't an error; It's just for your information.
Project not selected to build for this solution configuration
Open the configuration manager, select the solution configuration and solution platform. Then in the row for the project, select the project configuration and the project platform that you want built with the solution.
How to: Create and Edit Configurations
IIRC, Visual Studio Express has reduced configuration functionality. If that's a problem for you, you can edit the solution file with a text editor.
Check if the wix project build is selected with in the Configuration Manager -> Active Solution Platform -> "Any CPU".
Check this SO answer. In particular:
"WiX projects will not be built when building the 'Any CPU' platform
because Windows Installer packages are CPU-specific."
The nabble link in the SO answer is a reference to this wix-users mailing list entry and contains some useful links.

Unable to set build configuration to x64 in Visual Studio 2010

In one project's Properties | Build tab, only x86 is available for Platform. The x64 build option is missing. This is occurring in one project of a solution. The other projects are all still using x64. I tried creating an entirely new and separate solution/project and it is also only displays x86. Also, in the General section x64 is available and selected for Platform Target.
Can anyone explain why this is happening and how to fix it?

Problems with new build server

After moving my build server I get the following error:
C:\Windows\Microsoft.NET\Framework64\v3.5\Microsoft.Common.targets (1682): Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR2" and architecture "x64". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "MSBuildTaskHost.exe" exists and can be run.
My configuration says this:
<ConfigurationToBuild Include="Release|Any CPU">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>Any CPU</PlatformToBuild>
</ConfigurationToBuild>
What am I missing?
To resolve this, Go to your .csproj file and open with notepad.
Add the following line under the default property group:
<PropertyGroup>
<DisableOutOfProcTaskHost>true</DisableOutOfProcTaskHost>
</PropertyGroup>
Project should compile now.
In my case, I received that error message when trying to build a solution on a 32-bit Windows 7 machine. The way to resolve the error for me was to right-click on the project in VS, choose properties, then go to the Build tab. In here I changed the "Platform target" from "Any CPU" to "x86". HTH
Another approach is to do the following
Click Start ->> right-click Computer ->> Properties ->> Advanced system settings ->> click Environment Variables button to open the dialog,
then under the System variables section, click New… button, type the
Variable name = DISABLEOUTOFPROCTASKHOST, and type the Variable value = 1,
then click Ok.
This should suppress this error.
You need to install .NET SDK for the version of .NET that you are using.
Here is a link for .NET 3.5
Where is the .net 3.5 SDK?
and here is a link for 4.0
http://www.microsoft.com/en-us/download/details.aspx?id=8279
Installing Visual Studio will install the right SDK as well, but may not be a good option for you.
I hope that helps.
The core problem is the fact that an 64-bit executable can not load a 32-bit dll and vice-versa.
"Auto" means that . NET assembly will switch at runtime between the platforms, depending on what platform is on the machine it is currently running on.
So having a .NET assembly compiled with "Auto" loading an 32-bit dll is a problem waiting to happen, and this is what this error is all about.
To correct it, if you are NOT using any native dlls, go to the properties of the project for every managed project and set "target CPU" to be the same as currently selected "Platform", for all available platforms.
If you are using native dlls, you have to define 2 build configurations one for 32 bit and one for 64 bit, link (refer) the correct versions of the dlls and install according to the target computer platform.
I resolved this issue by opening VS2010 as administrator.

How to correct the Platform to AnyCPU in a multiple-project solution in Visual Studio?

I had a solution with one project set to AnyCPU. Then I added a Console application as a second project, who's default Platform seems to be x86. Now it's ( - the Console application) being built as an x86 and I can't change it.
The "Solution Platform" always shows "AnyCPU". But when I show the Console application's properties -> build. It shows x86 without any way to change it. So how do I change it?
Go to Build -> Configuration Manager
Select for the overall solution the Active Platform = AnyCPU
Go to the Console Application line and Set the Platform to AnyCPU
If there isn't the voice create a new configuration
Check that the Console Application is flagged for compile.
Also look at this discussion about console applications default to x86
This is an unfortunate flaw in the VS user interface design. The solution's Platform name is not relevant for managed projects, it only means something for native C++ projects. Where "AnyCPU" doesn't mean anything since native code cannot run on any cpu. This got a wee bit better in VS2010 with a new default Platform name of "x86". Merely a wee.
The only setting that really counts is the Platform target setting for the EXE project. Project + Properties, Compile tab for a C# project. The class library project settings are not relevant either since it is the EXE that nails down the bitness of the process.
Best thing to do is just ignore it. You can make that more permanent with Tools + Customize and just drag the combobox off the toolbar so you don't have to look at it again.

Resources