Visual Studio 2017项目依赖与nuget版本控制 [英] Visual Studio 2017 project dependency with nuget version control

查看:114
本文介绍了Visual Studio 2017项目依赖与nuget版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我目前有一个Visual Studio 2017解决方案,它有多个项目构建Nuget包。

某个项目具有对其他项目的项目引用,因此生成nuget包具有依赖项自动注入。我想知道的是如何在项目参考包中加上一个上限,即(verison
> = [项目A版本] 和版本< 2.0.0;硬编码上限值)。目前所有的项目参考只给我以下版本> = [项目A版本]。 

这会阻止我们使用sementic版本来控制重大变化。 有没有人经历和考虑过这个?

谢谢,




例如   解决方案A

E.g.   Solution A

  &NBSP; &NBSP; &NBSP; &NBSP;   | - 项目A(生成版本1.0.0的nuget包)

           |- project A (generate nuget package with version 1.0.0)

  &NBSP; &NBSP; &NBSP; &NBSP;   | - 项目B(参考项目A nuget包生成nuget包)  < - 我想限制项目的包版本。

           |- project B (generate nuget package with reference to project A nuget package)  <- I want to limit the package version from the project.

推荐答案

您好Wil168,

Hi Wil168,

感谢您在此处发帖。

>> ;>这会阻止我们使用sementic版本来控制重大更改。 有没有人经历并考虑过这个?

>>>What happens is that this stop us from using sementic version to control breaking changes.  Have anyone experience and consider this at all?

这是"允许ProjectReference的上限版本"的阻止问题,nuget团队正在工作关于这个问题。您可以从以下主题查看详细信息:

This is a blocking issue for "Allow an upper limit Version for ProjectReference", The nuget team is working on the problem. You can check the details from following thread:

https://github.com/ NuGet / Home / issues / 5556

作为一种解决方法,我们可以通过添加项目参考的限制版本手动打包项目B和.nuspec文件,以下是项目B的.nuspec文件:

As a workaround, we could manually pack the project B with .nuspec file by adding the  limit version for project reference, following is my .nuspec file for project B:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>ProjectB</id>
    <version>1.0.0</version>
    <authors>Tester</authors>
    <owners>Tester</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2018</copyright>
    <tags>Tag1 Tag2</tags>
    <dependencies>
      <dependency id="ProjectA" version="[1.0.0, 3.0.0]" />
    </dependencies>
  </metadata>

  <files>
    <file src="bin\Debug\netstandard2.0\ProjectB.dll" target="lib\netstandard2.0\ProjectB.dll" />
  </files>
</package>

使用nuget命令行打包此.nuspec文件后:nuget pack" xxx.nuspec",您将获得nuget包:

After pack this .nuspec file with nuget command line: nuget pack "xxx.nuspec", you will get the nuget package:

希望这会有所帮助。


这篇关于Visual Studio 2017项目依赖与nuget版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆