简体   繁体   中英

Build C# standard project with the latest versions of the nuget references

When using new C# projects we don't have packages.config files. The dependencies are specified inside the *.proj file, something like:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="XYZ.Definitions" Version="1.0.0-CI-20181010-102209" />
    <PackageReference Include="XYZ.Definitions.Common" Version="1.0.0-CI-20181010-102209" />
  </ItemGroup>
</Project>

How can I specify that I always want to build with the latest versions available of my references?

I was thinking something like:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="XYZ.Definitions" Version="latest" />
    <PackageReference Include="XYZ.Definitions.Common" Version="latest" />
  </ItemGroup>
</Project>

I dont know if this is even possible. Also here you can find a solution but in another context, that is using packages.config and nuget.config files.

* will use the latest stable version available.

Solution:

<PackageReference Include="XYZ.Definitions" Version="*" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM