ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

c#-.NET分析器:程序包版本与程序集版本

2019-10-25 10:06:05  阅读:388  来源: 互联网

标签:nuget visual-studio-2017 c net


如下图所示,当使用VS 2017创建带有代码修复(.NET Standard)的Analyzer类型的项目时,在项目的属性选项卡中有程序包版本,程序集版本和程序集文件版本.

enter image description here

这3个版本是否相互关联?另外,当我在项目中进行更改时,应该如何更改版本号?例如,如果我修复了错误,添加了新规则等.

解决方法:

Are those 3 versions related together or not? Also, as I make changes in the project how am I supposed to change the versions number? For instance, if I fix a bug, if I add a new rule, etc.

在回答这个问题之前,我们需要了解一些有关AssemblyVersion和AssemblyFileVersion的信息.

Assembly Version: This is the version that .Net looks at during run-time for loading packages and finding types.

Assembly File Version: This defines the version reported by the OS to other applications like Windows Explorer.

您可以查看Rémy van Duijkeren`s answer了解更多详细信息.

但是,NuGet不使用这两种方法.它使用第三个版本控制属性:AssemblyInformationalVersion-程序集的产品版本.

它使用此属性,因为似乎没有其他人关心它.操作系统或.Net没有使用该信息版本,这意味着NuGet可以使用它.但是此版本控制属性已在AssemblyInfo.cs文件中删除,因为它们不适用于语义版本控制.

当您使用VS 2017使用代码修复(.NET Standard)使用分析器类型的项目时,这些属性设置已移至.csproj文件中.默认情况下,它们不会显示,但是您可以从Visual Studio 2017的项目属性“程序包”选项卡中找到它们:

enter image description here

保存后,可以在MyProject.csproj中找到这些值:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <Version>1.2.3.4</Version>
    <Authors>Author 1</Authors>
    <Company>Company XYZ</Company>
    <Product>Product 2</Product>
    <PackageId>MyApp</PackageId>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
    <FileVersion>3.0.0.0</FileVersion>
    <NeutralLanguage>en</NeutralLanguage>
    <Description>Description here</Description>
    <Copyright>Copyright</Copyright>
    <PackageLicenseUrl>License URL</PackageLicenseUrl>
    <PackageProjectUrl>Project URL</PackageProjectUrl>
    <PackageIconUrl>Icon URL</PackageIconUrl>
    <RepositoryUrl>Repo URL</RepositoryUrl>
    <RepositoryType>Repo type</RepositoryType>
    <PackageTags>Tags</PackageTags>
    <PackageReleaseNotes>Release</PackageReleaseNotes>
  </PropertyGroup>

在文件资源管理器属性信息选项卡中,版本显示为“产品版本”,供NuGet使用.就像版本控制属性:AssemblyInformationalVersion.

因此,如果您修复了错误或添加了新规则,则可以更改软件包版本以运送新软件包.

major is incremented for a breaking change, minor for a change that
is backwards compatible and patch for bug fixes.

至于是否需要修改程序集版本的版本号,请参考this document了解更多详细信息.

希望这可以帮助.

标签:nuget,visual-studio-2017,c,net
来源: https://codeday.me/bug/20191025/1927756.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有