问题描述
我有Windows 7 64位计算机。以下是dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100\
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
3.0.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNe
tCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.
App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.W
indowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
以下是我的csproj文件
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
</PropertyGroup>
</Project>
当我尝试运行dotnet build -r linux-x64
时,出现以下错误
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
copyright (C) Microsoft Corporation. All rights reserved.
error NU1100: Unable to resolve 'Microsoft.NETCore.App.Runtime.linux-x64 (= 3.0.0)' for '.NETCoreApp,Version=v3.0'.
error NU1100: Unable to resolve 'Microsoft.AspNetCore.App.Runtime.linux-x64 (= 3.0.0)' for '.NETCoreApp,Version=v3.0'.
error NU1100: Unable to resolve 'Microsoft.NETCore.App.Host.linux-x64 (= 3.0.0)' for '.NETCoreApp,Version=v3.0'.
Restore Failed in 117.05 ms for C:\Users\viraj\Documents\Projects\MS\SampleWebApi\SampleWebApi.csproj.
Build Failed.
error NU1100: Unable to resolve 'Microsoft.NETCore.App.Runtime.linux-x64 (= 3.0.0)' for '.NETCoreApp,Version=v3.0'.
0 Warning(s)
3 Error(s)
Time Elapsed 00:00:00.76
我想我没有在Windows机器上安装运行时。但是我不确定如何在Windows计算机上为Linux添加运行时。我找不到任何文档。 我最终希望将其部署在Linux机器上。
解决方法
我认为那是因为您没有使用Windows路径
,问题是因为VS代码不会自动从nuget.org中提取。
创建Nuget.config文件并添加nuget.org软件包源已修复该文件。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>