Configure .NET Core to use x86 SDK

China☆狼群 提交于 2019-12-07 03:01:43

问题


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!


回答1:


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.




回答2:


For some reason, my install didn't even add the PATH variable. Adding the 64-bit path variable and restarting visual studio worked for me.




回答3:


The issue is known, once the previous versions have been uninstalled

The install this based on the correct release version and target platform




回答4:


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.



来源:https://stackoverflow.com/questions/39497807/configure-net-core-to-use-x86-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!