[英]How to restore or install Nuget packages from copy then paste to *.csproj file?
I am using Microsoft Visual Studio Community 2019 Preview - Version 16.8.0 Preview 2.0 , .NET Core 5.0.100-preview.8.20417.9
, ASP.NET Core 5.0-preview Web API.我正在使用 Microsoft Visual Studio Community 2019 Preview - Version 16.8.0 Preview 2.0、.NET Core
5.0.100-preview.8.20417.9
、ASP.NET Core 5.0-preview Web API。 Original file *.csproj
原始文件
*.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
Then I add (copy a part from another projects manually)然后我添加(手动从另一个项目复制一部分)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.Polly" Version="3.5.0.5" />
<PackageReference Include="ChilkatNativeLib" Version="9.5.0.83" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.24" />
<PackageReference Include="HtmlAgilityPack.NetCore" Version="1.5.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-preview.8.20407.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0-preview.8.20407.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-preview.8.20407.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.0-preview.8.20419.1" />
<PackageReference Include="MimeKit" Version="2.9.1" />
<PackageReference Include="NAudio" Version="1.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="RestSharp" Version="106.11.5-alpha.0.18" />
<PackageReference Include="SendGrid" Version="9.21.0" />
<PackageReference Include="Serilog" Version="2.10.0-dev-01240" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.5.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="System.ServiceModel.Syndication" Version="5.0.0-preview.8.20407.11" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0-preview.8.20407.11" />
</ItemGroup>
</Project>
Then I run然后我跑
dotnet restore
but not success.但不是成功。
How to restore or install Nuget packages from copy then paste to *.csproj
file?如何从复制恢复或安装 Nuget 包然后粘贴到
*.csproj
文件?
How to restore or install Nuget packages from copy then paste to *.csproj file?
如何从复制恢复或安装 Nuget 包然后粘贴到 *.csproj 文件?
I think it is an issue on Visual Studio Preview 16.8 with Net Core 5.0.我认为这是带有 Net Core 5.0 的 Visual Studio Preview 16.8 的问题。
First of all , update-package -reinstall
command cannot be used for Net Core project, it is used for Net Framework projects with packages.config nuget management format.首先,
update-package -reinstall
命令不能用于 Net Core 项目,它用于具有packages.config nuget 管理格式的 Net Framework 项目。
For Net Core projects, you can just click build which will restore nuget packages.对于Net Core项目,您只需单击 build 即可恢复 nuget 包。
Actually , when you install the nuget package on the Net Core 5.0 project, it restores packages successfully on the global nuget folder.实际上,当您在Net Core 5.0项目上安装 nuget 包时,它会在全局 nuget 文件夹中成功还原包。
You can first delete all nuget packages under C:\\Users\\xxx(current user)\\.nuget\\packages
and then rebuild your project.您可以先删除
C:\\Users\\xxx(current user)\\.nuget\\packages
下的所有 nuget C:\\Users\\xxx(current user)\\.nuget\\packages
,然后重建您的项目。
The packages will all restore under that folder.软件包将全部恢复到该文件夹下。
==================================================================== ================================================== ==================
But however, the main issue is that:但是,主要问题是:
For Net Core 5.0
, nuget package has no name and reference path though it can be restored and build without any warnings and errors.对于
Net Core 5.0
,nuget 包没有名称和引用路径,尽管它可以在没有任何警告和错误的情况下进行恢复和构建。
While in Net Core 3.1,
it has the name and full reference path so that VS can find it.而在
Net Core 3.1,
它具有名称和完整的引用路径,以便 VS 可以找到它。
That's why the yellow triangle occurs.这就是黄色三角形出现的原因。 And not sure whether this behavior will affects your developing.
并且不确定这种行为是否会影响您的发展。
And the name and path are the given by the system and we cannot change it.并且名称和路径是系统给定的,我们无法更改。
You can try to change your project from Net Core 5.0
to Net Core 3.1
, I am sure that most of the yellow triangles will disappear.您可以尝试将您的项目从
Net Core 5.0
更改为Net Core 3.1
,我相信大多数黄色三角形都会消失。
Since it is an issue , I have reported it to our DC Forum .由于这是一个问题, 我已将其报告给我们的 DC 论坛。
You can vote it or add any comments if I did not describe the issue in detail.如果我没有详细描述问题,您可以投票或添加任何评论。 And I hope the Team will check the issue and resolve the issue as soon as possible.
我希望团队能尽快检查问题并解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.