我正在寻找一种在构建时设置 .net core 库的程序集版本(以及文件版本和 nuget 包版本)的方法。我的库是使用最新的 Visual Studio 2017 RC 编写的,因此不再需要projects.json
文件,并由 TeamCity 使用标准 powershell 构建脚本构建,该脚本调用dotnet restore
dotnet build
dotnet test
而且当然dotnet pack
.
一直在网上寻找一个优雅的解决方案,但还没有找到任何接近它的东西。我在互联网上能找到的都是现在已经过时的xproj
and projects.json
format.
我很惊讶的是dotnet build
and dotnet pack
命令不支持开箱即用。
谢谢 :)
如果其他人出现并需要这个,请将其添加到您的 csproj 中:
<PropertyGroup>
<Version>1.2.3.4</Version>
<PackageId>$(AssemblyName)</PackageId>
<Title>My Super Library</Title>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<Company>AwesomeCo, Inc.</Company>
<Product>My Super Library</Product>
<Copyright>Copyright © AwesomeCo, Inc. 2016-2017</Copyright>
<Description>There can be only one.</Description>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<GenerateAssemblyTitleAttribute>true</GenerateAssemblyTitleAttribute>
<GenerateAssemblyConfigurationAttribute>true</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>true</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>true</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>true</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>true</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>
Our PackageId
显然与我们的项目名称相同,但您可以更改它。
您可以在 csproj 中硬编码 $(Version) ,或者在发布/打包时将其发送:
dotnet publish /property:Version=1.2.3.4
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)