简体   繁体   中英

NuGet package version and NuGet Id

I have one Project.sln in my GitRepo. And I need to build 4 NuGet packages with different configurations ( local , qa , sandbox and production ). I'm using TeamCity with Octopus Deploy.

In TeamCity my Build Configuration has the following Build Steps:

1) NuGet Installer
2) Build Project.sln with *Local* Configuration
3) NuGet Pack with using .csproj file

4) NuGet Installer
5) Build Project.sln with *QA* Configuration
6) NuGet Pack with using .csproj file

7) NuGet Installer
8) Build Project.sln with *Sandbox* Configuration
9) NuGet Pack with using .csproj file

10) NuGet Installer
11) Build Project.sln with *Production* Configuration
12) NuGet Pack with using .csproj file

And I have the following problems:

1) When I'm using AssemblyInfo patcher it makes only one NuGet package file. On step number 3 TeamCity creates a package with name 2.2.1.%build.counter% . And on step number 6 it creates a package with the same name and overwrites it. It does the same on steps 9 and 12. Finally I have only one NuGet package with last configuration (in my case it's Production ).

I want to have 4 packages like:

2.2.1.%build.counter%_local
2.2.1.%build.counter%_qa
2.2.1.%build.counter%_sandbox
2.2.1.%build.counter%_production

2) The next problem is with Octopus. When TeamCity makes packages (it makes 4 packages, but without AssemblyInfo patcher ), it makes them with the same id (Project) and when I'm trying to Deploy "some" (let it be QA) package to the QA environment, Octopus asks me to select the id of a NuGet package. And it only sees one id - " Project ". I think it is the last package created by TeamCity.

I would suggest to create TeamCity configuration for each NuGet package you need. Or patch and build manually instead of build-in NuGet support.

You can achieve your goal by creating nuget packages (nuget pack step) from .nuspec files.

Here is the most common example of this file (1 of 4 in your case)

<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <id>yourProcjectName.qa</id>
    <version>1.0.0</version>
    <authors>Jay Hamlin</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Simple Description</description>
  </metadata>
  <files>
    <file src="bin\Release\*.dll" target="lib" />
  </files>
</package>
  1. First of all in 'id' section specify .
  2. 'Version' section could be override by TeamCity property. Here is example:

在此输入图像描述

  1. Nuget pack will create package and name it from template: {package_id}.{version}.nupkg (or {version}.{package_id}.nupkg - I don't remember)

  2. Now you must simply publish your packages to octopus nuget server. Package will have the same name as id, so if you create 4 different .nuspec configurations you will have 4 packages with diffrent names but same version.

Ps. You can check your nuspec files by opening them in nuget package explorer ( LINK )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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