0

I have a Visual Studio 2015 Solution which contains multiple projects. Some of these projects reference each other. Example

Solution
   Project A
   Project B - references Project A

On teamcity, I want to create nuget packages for each of these projects, such that when Nuget is generating a package from Project B, I want it to be aware that Project A has a Nuget package and reference that Nuget package instead of having to use the -IncludeReferencedProjects flag.

Is this possible? If yes, how?

Obi
  • 3,091
  • 4
  • 34
  • 56

1 Answers1

2

Using VS 2017 (or the dotnet cli tooling - labelled ".net core SDK") you can build libraries using the new sdk-based csproj tooling that have exactly that behaviour: Each project will produce a separate NuGet package and project references will be replaced with NuGet dependencies.

To do that, use the .NET Standard Library project template (or dotnet new lib on the commandline) - if you want to build your libraries for the .NET Framework, change the content of the <TargetFramework>element in the csproj file from netstandard1.4 to e.g. net461 (there just isn't a .NET Framework library template (yet?) that uses the new project system / tooling).

To build nuget packages you then use dotnet pack or msbuild /t:Packin your CI build (there is a TeamCity plugin for building with the .net core tools as well. See https://blog.jetbrains.com/teamcity/2016/11/teamcity-dotnet-core/).

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • Hi Martin, thanks...I forgot to mention that I am using VS 2015 – Obi May 08 '17 at 07:22
  • Well.. if you want that as an easy feature, that's a reason to upgrade. Nuget <4 / vs2015 solutions would require hand-editing nuspec files or writing scripts to generate them which is a pain to set up and maintain. – Martin Ullrich May 08 '17 at 07:29