Teamcity nuget packaging problem

We have a TeamCity build project for a .Net Standard 2.0 class library project. We want to build the project and create a nuget package which is published to TeamCity internal feed. 

Everything works fine until trying to consume the nuget package from another .Net Standard 2.0 project with the following error:

Package 'Commo.1.0.1' was restored using '.NetFramework, Version=v4.6.1' instead of the project target framework '.NetStandard, Version=v2.0'. This package may not be fully compatible with your project.

 

The TeamCity version is "2017.1 (build 46533)" with Nuget.EXE 4.5.1 and the server has .NetCore SDK  2.1.4 installed .

The two build steps are:

Step 1 - Build

 

Step 2: Create package

We've also specified "TargetFrameworkVersion=netstandard2.0" in the Properties field of package creating step, but it still gives the following warning when consuming the package which seems to suggest the package was created to target .NetFramework 4.6.1.

Really appreciate if anyone could shed some light on this issue.

 

 

 

 

0
9 comments
Avatar
Nikolay Pianikov
Official comment

Hi, you could update the plugin from:
https://github.com/JetBrains/teamcity-dotnet-plugin

Also I would suggest you to use the following commands to build your solution and to pack:

1. Replace you .nusec file by .csproj metadata, for example the .csproj file:

`
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks>net40;net47;netstandard1.0;netcoreapp2.0</TargetFrameworks>
<PackageId>...</PackageId>
<Authors>...</Authors>
<Description>...</Description>
<PackageLicenseUrl>...</PackageLicenseUrl>
<PackageProjectUrl>...</PackageProjectUrl>
<PackageIconUrl>...</PackageIconUrl>
<RepositoryUrl>...</RepositoryUrl>
<RepositoryType>...</RepositoryType>
<PackageTags>...</PackageTags>
<Product>...</Product>
<Copyright>...</Copyright>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<TargetFrameworks>netstandard1.0;netstandard1.1;netstandard1.2;netstandard1.3;netstandard1.4;netstandard1.5;netstandard1.6;netstandard2.0;net40;net45;net46;net47;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<Optimize>true</Optimize>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

</Project>
`

2. Just use `dotnet build ..` to build as you have already done

3. Use `dotnet pack` to make a nuget package automatically for all specified frameworks (also it adds metadata for dependencies).

4. To pass a version for you package and assembly you could add the system property for your build configuration, for example: `system.version = 1.1.0-beta%build.number%`

 

But if you wanted to fix this issue without these changes it would be better to share your .nuspec and .csproj

Avatar
Permanently deleted user

Thanks Nikolay.

The .nuspec is

<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
        <version>0.00</version>
        <authors>IT</authors>
        <owners>IT</owners>
        <id>.Common</id>
        <title>Common</title>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
       <description>Common Library</description>
       <copyright>Copyright 2018</copyright>
       </metadata>
   <files>
         <file src="bin\Release\netstandard2.0\Common.dll" target="lib\Common.dll" />
   </files>
</package>

The .csproj file is

<Project Sdk="Microsoft.NET.Sdk">   

    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
   </PropertyGroup>

</Project>

 

0
Avatar
Nikolay Pianikov

Try changing the line 

`<file src="bin\Release\netstandard2.0\Common.dll" target="lib\Common.dll" />`

to

`<file src="bin\Release\netstandard2.0\Common.dll" target="lib\netstandard2.0\Common.dll" />`

0
Avatar
Permanently deleted user

that change doesn't work.

0
Avatar
Nikolay Pianikov

Is it possible to share a structure of directories with lists of files in your new .nuget package? Also a content of .nuspec

0
Avatar
Permanently deleted user

nuget package structure including TeamCity directories:

Nuspec content

<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
           <version>0.00</version>
           <authors> IT</authors>
           <owners> IT</owners>
           <id>Common</id>
           <title>Common</title>
           <requireLicenseAcceptance>false</requireLicenseAcceptance>
          <description>Common Library</description>
          <copyright>Copyright 2018</copyright>
      </metadata>
     <files>
         <file src="bin\Release\netstandard2.0\Common.dll" target="lib\netstandard2.0\Common.dll" />
      </files>
</package>

 

 

0
Avatar
Nikolay Pianikov

Looks fine.

Could you try cleaning nuget cache and try again? I cannot reproduce the similar scenario. Is it possible to share some simple VS solution thar reproduces your issue?

 

0
Avatar
Permanently deleted user

The VS solution is just a standard one. You can just create a class lib for .Net Standard 2.0 from Visual Studio 2017

0
Avatar
Permanently deleted user

Was this ever solved? Im running into the same issue.

 

Netstandard2.0 library which builds and is accessible from TC Nuget feed.

 

I have another console app that refs the package which is fine from VS. I specify the --source in a dotnet pack step and then I see the issue.

0

Please sign in to leave a comment.