Visual Studio 2019 .CSPROJ安装最新的Nuget版本

发布于 2025-02-02 00:39:29 字数 1315 浏览 6 评论 0 原文

我有一个非常简单的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
enter image description here

Under the manage nuget package window I can see a newer version 1.1.0
enter image description here

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

enter image description here

How can I tell VS2019 to automatically install the latest version of my NuGet package?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

翻身的咸鱼 2025-02-09 00:39:29

根据您的描述,我进行了一些与您的问题有关的测试,但无法再现您的问题。
您可以尝试这些建议,让我知道它是否不起作用。

  1. 您可以使用工具&gt; gt; nuget软件包管理器清除所有Nuget Caches。将其添加到您的.csproj文件“”中,然后重建项目。
  2. 您可以更改包源以检查其他软件包是否可以使用版本=”*”。
  3. 如果您获得有关此问题的任何更新,请告诉我。

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.

  1. You can go to Tools>Options>NuGet Package Manager to Clear All NuGet Caches. Add this in your .csproj file “” and rebuild the project.
    enter image description here
  2. You can change a package source to check if other packages can use Version=”*”.
  3. Please let me know If you get any update about the issue.
2025-02-09 00:39:29

您不能,因为不同的版本会更改依赖性,并可能引入破坏变化。

如果您设置了项目,请始终使用最新功能,这意味着它会在某个时候破裂,因为您的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文