配置.NET Core以使用x86 SDK

问题描述 投票:6回答:4

我正在尝试更改我的.NET Core Web应用程序以使用x86版本的.NET Core SDK。

我从here安装了x86版本。我可以在C:\ Program Files(x86)\ dotnet \ sdk \ 1.0.0-preview2-003131中看到它

我将global.json更新为:

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

但我得到错误:

该项目配置为使用.NET Core SDK版本1.0.0-preview2-003131,该版本未安装或无法在路径C:\ Program Files \ dotnet下找到。构建和运行此项目需要这些组件。下载global.json中指定的.NET Core SDK版本,或将global.json中的SDK版本更新为已安装的版本。

我想我需要告诉我的应用程序查看C:\ Program Files(x86)\ dotnet

我该怎么做呢?

谢谢你的帮助!

.net asp.net-core .net-core asp.net-core-1.0
4个回答
6
投票

找到了解决方案。

当我安装x64版本时,它在我的PATH环境变量中创建了一个名为C:\ Program Files \ dotnet的条目。我卸载了x64版本并安装了x86版本。但是,卸载x64版本并未从我的PATH中删除C:\ Program Files \ dotnet。因此,我手动删除它,并确保x86版本添加的条目C:\ Program Files(x86)\ dotnet存在。


1
投票

出于某种原因,我的安装甚至没有添加PATH变量。添加64位路径变量并重新启动visual studio对我有用。


1
投票

一旦卸载了以前的版本,就会出现此问题

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


1
投票

您可以通过在项目的根目录中创建Directory.Build.targets文件来解决此问题。

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

现在,安装了两个SDK(x64,x86)后,编译器将找到正确的平台,如项目构建设置中所指定的那样。

© www.soinside.com 2019 - 2024. All rights reserved.