我有一个非常简单的vs2019 .csproj文件,可以在下面看到:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AST.NxTestware.main" Version="1.0.0" />
</ItemGroup>
</Project>
当我保存csproj文件时,我可以在右侧看到依赖项,我可以在PC上找到已安装的Nuget软件包
在管理Nuget软件包窗口下,我可以看到一个较新的版本1.1.0
我想编辑.csproj文件,以便它始终安装最新的Nuget软件包版本,并且我尝试通过设置 version =“*”
来尝试这样做。
但是设置版本=*导致我的VS2019依赖项列表显示一个黄色警告圈,现在不会消失,如果我检查我的本地Nuget安装文件夹,我可以看到任何东西都没有安装
如何告诉VS2019自动安装最新版本的Nuget软件包?
I have a very simple VS2019 .csproj file which can be seen below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AST.NxTestware.main" Version="1.0.0" />
</ItemGroup>
</Project>
When I save the csproj file, I can see in my right hand side the dependency is downloaded, and I can find the installed NuGet package on my PC

Under the manage nuget package window I can see a newer version 1.1.0

I want to edit my .csproj file so that it always installs the most recent NuGet package version, and I tried doing so by setting version="*"
https://learn.microsoft.com/en-us/nuget/concepts/package-versioning
but setting version=* causes my VS2019 dependency list to show a yellow warning circle now which wont go away, and if I check my local NuGet installation folder I can see that nothing got installed

How can I tell VS2019 to automatically install the latest version of my NuGet package?
发布评论
评论(2)
根据您的描述,我进行了一些与您的问题有关的测试,但无法再现您的问题。
您可以尝试这些建议,让我知道它是否不起作用。
According to your description, I did some tests related to your problem, but could not reproduce your problem.
You can try these suggestions and let me know if it doesn't work.
您不能,因为不同的版本会更改依赖性,并可能引入破坏变化。
如果您设置了项目,请始终使用最新功能,这意味着它会在某个时候破裂,因为您的nugets会更新,但不能更新您的代码来处理新版本。
可以这么说,一旦收集了一个项目,DLL将设置为石头,因此它不能仅仅重写其字节码以获取最新的Nuget。
You can't, because different versions change dependencies and may introduce breaking changes.
If you set you project to always use the latest this means it will break at some point as your nugets would update but not your code to handle the new version.
Furthermore once a project is compiled the dlls are set in stone, so to speak, so it can't just rewrite its bytecode to get the latest nuget.