简体   繁体   English

nuget:软件包版本未更新

[英]nuget: package version is not being updated

I'm trying to pack a new version of a custom NuGet package and when I use the pack command I'm getting a .nupkg file which has a version number that doesn't match with the one that I've specified in the .nuspec file . 我正在尝试打包自定义NuGet软件包的新版本,当我使用pack命令时,我得到的是一个.nupkg文件,该文件的版本号与我在中指定的版本号不匹配.nuspec file

Example: 例:

nuget pack mypackage.csproj -IncludeReferencedProjects -Prop Configuration=Release

.nuspec file: .nuspec文件:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>mypackage</id>
    <version>1.0.1</version>
    <authors>me</authors>
    <owners>me</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>blah</description>
    <releaseNotes></releaseNotes>
    <copyright>Copyright 2016</copyright>
    <tags>tag1 tag2</tags>
    <dependencies>
    </dependencies>
  </metadata>
</package>

I should get a file named mypackage.1.0.1.nupkg , but I'm getting a file named mypackage.1.0.0.nupkg instead 我应该得到一个名为mypackage.1.0.1.nupkg的文件,但我却得到了一个名为mypackage.1.0.0.nupkg的文件。

I'm also getting the same result when I try to pack it by using the AssemblyInfo data included in the Properties\\AssemblyInfo.cs and declaring the version as a variable in the .nuspec file: 当我尝试通过使用Properties\\AssemblyInfo.cs包含的AssemblyInfo数据并在.nuspec文件中将版本声明为变量时,将其打包时,也会得到相同的结果:

Properties\\AssemblyInfo.cs ... [assembly: AssemblyVersion("1.0.1")] ... Properties \\ AssemblyInfo.cs ... [assembly:AssemblyVersion(“ 1.0.1”)] ...

Should I look for another properties in my project to update my NuGet package? 我是否应该在项目中寻找其他属性来更新NuGet包?

SOLUTION: Ignored the .nuspec file and managed the package versions via .csproj 解决方案:忽略.nuspec文件,并通过.csproj管理软件包版本

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net451;net452</TargetFrameworks>
    ...
    <AssemblyVersion>1.2.1</AssemblyVersion>
</Project>

Thanks in advance! 提前致谢!

I fell foul of this recent as well. 我也对这个最近犯规。 You need to use the Properties\\AssemblyFileVersion attribute to set the correct value for a nuget package 您需要使用Properties \\ AssemblyFileVersion属性为nuget包设置正确的值

[assembly: AssemblyFileVersion("1.0.1")]
  1. Make sure to change both the Assembly Version and File Version in Project Properties > Application > Assembly Information. 确保在项目属性>应用程序>程序集信息中更改程序集版本和文件版本。
  2. After that make sure you are set to Release mode and build your project. 之后,请确保将您设置为发布模式并构建您的项目。
  3. Execute the Nuget Spec command in your project's folder 在您的项目文件夹中执行Nuget Spec命令
  4. Edit the Spec, version should be set to $version$ so as to grab it from your project, remove the lines that need removing, fill the ones with placeholders. 编辑规范,版本应设置为$ version $,以便从您的项目中获取它,删除需要删除的行,并用占位符填充行。
  5. Execute your Nuget Pack command in the same folder and you should be good. 在同一文件夹中执行您的Nuget Pack命令,您应该会很好。

I often forget to build my project so it doesn't update the version. 我经常忘记构建我的项目,因此它不会更新版本。

Well, I've finally managed to update my version by packing using the AssemblyInfo version. 好了,我终于设法通过使用AssemblyInfo版本打包来更新我的版本。 It seems like my publishing process for this package is completely ignoring the .nuspec file and gets the version from the last compiled source. 看来我对此程序包的发布过程完全忽略了.nuspec文件,并从最后编译的源获取版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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