Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure .NET Core to use x86 SDK

I'm trying to change my .NET Core Web Application to use the x86 version of the .NET Core SDK.

I installed the x86 version from here. I can see it in C:\Program Files (x86)\dotnet\sdk\1.0.0-preview2-003131

I updated my global.json to this:

{
    "projects": [ "src" ],
    "sdk": {
        "version": "1.0.0-preview2-003131",
        "architecture": "x86"
    }
}

But I get the error:

The project is configured to use .NET Core SDK version 1.0.0-preview2-003131 which is not installed or cannot be found under the path C:\Program Files\dotnet. These components are required to build and run this project. Download the version of .NET Core SDK specified in global.json or update the SDK version in global.json to the version that is installed.

I guess I need to tell my application to look in C:\Program Files (x86)\dotnet

How do I do this?

Thanks for any help!

like image 936
John-Luke Laue Avatar asked Sep 14 '16 19:09

John-Luke Laue


2 Answers

Found the solution.

When I installed the x64 version, it created an entry in my PATH environment variable called C:\Program Files\dotnet. I uninstalled the x64 version and installed the x86 version. However, the un-installation of the x64 version did not remove the C:\Program Files\dotnet from my PATH. So, I removed it manually, and made sure that the entry that the x86 version added, C:\Program Files (x86)\dotnet, existed.

like image 76
John-Luke Laue Avatar answered Sep 30 '22 11:09

John-Luke Laue


You can sort out this issue by creating a Directory.Build.targets file in the root of your project.

<Project>
  <PropertyGroup 
      Condition="'$(OS)' == 'Windows_NT' and
                 '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
                 '$(SelfContained)' != 'true'"
                  >
    <RunCommand Condition="'$(PlatformTarget)' == 'x86'">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
    <RunCommand Condition="'$(PlatformTarget)' == 'x64'">$(ProgramW6432)\dotnet\dotnet</RunCommand>
  </PropertyGroup>
</Project>

Now, with both SDKs installed (x64, x86), the compiler will find the correct platform, as specified in your project build settings.

like image 38
asdf Avatar answered Sep 30 '22 13:09

asdf