Package version is always 1.0.0 with dotnet pack

Package version is always 1.0.0 with dotnet pack

https://github.com/kerryjiang/SuperSocket/blob/master/Directory.Build.props

 

When you use dotnet pack, the version is pulled from the project definition (previously project.json, now *.csproj), not AssemblyInfo.cs. So, your new workflow will be very similar to what it was with project.json.

From the project.json to csproj migration docs, you can use the VersionPrefix and VersionSuffix properties.

Before:

{
  "version": "1.0.0-alpha-*"
}

Now:

<PropertyGroup>
  <VersionPrefix>1.0.0</VersionPrefix>
  <VersionSuffix>alpha</VersionSuffix>
</PropertyGroup>

You can also use the single Version property, but the docs warn that this "may override version settings during packaging".

<PropertyGroup>
  <Version>1.0.0-alpha</Version>
</PropertyGroup>

 

使用NetRevisionTask遇到的问题

project本身是不带version的信息的,在最后编译的时候,生成dll的时候才附带version信息。

这样导致nuget发布后依赖dll文件都是>=1.0,然而dotnet build生成的dll文件是附带版本的。

比如projectB依赖于projectA,发布projectB的时候,projectA的依赖是》=1.0.

然后build之后,projectA和projectB有可能是编译成同一个版本1.1.3的,这样导致打包的projectB.dll文件里面会强绑定projectA的版本1.1.3.。

解决方案:

每个project有自己的单独版本,手动升级版本。dotnet build之后的projectA的版本是固定的,而不是动态变化的。

 

posted @ 2020-06-09 18:04  ChuckLu  阅读(309)  评论(0编辑  收藏  举报