11

I am trying to create a nuget package for my web application but it is not producing any .nupkg outputs. I am using Visual Studio 2017 15.3.0.

To create the project I do the following:

  • File - New - Project,
  • Visual C# - Web,
  • Asp.Net Core Web Application,
  • Web Application

Then I go to a command prompt in the directory with the csproj file in and type: "Dotnet Pack"

I get only the following output:

Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

But no nuget packages are created. I am expecting something like:

Producing Nuget Package "App.1.0.0" for App

Do I need to do anything else eg to the csproj file ?

hardkoded
  • 18,915
  • 3
  • 52
  • 64
Frank Cannon
  • 1,643
  • 2
  • 18
  • 29
  • 3
    So you expect to create a nuget package from a website? not saying it's right or wrong, but what would you expect from that package? – hardkoded Sep 05 '17 at 14:29
  • Its so that I can produce a Nuget package in TeamCity that can be deployed by Octopus Deploy. Correct me if there is a better way. – Frank Cannon Sep 05 '17 at 14:44
  • Octopus Deploy suggests to use `dotnet publish` to generate a published output and then use `octo pack` on that output. Please consult [its documentation](https://octopus.com/docs/guides/deploying-asp.net-core-web-applications). – Martin Ullrich Sep 05 '17 at 14:51
  • I am in the same situation as wanting to deploy from vsts builds into managed openshift platform. The managed platform wants to choose the Docker runtime so that a dozen teams don't have to change their Docker files for security patches. Not having a way to deploy an asp.net core website as a package means that I will need to ship zip files around – simbo1905 Oct 21 '17 at 09:02

2 Answers2

27

Web applications are not packable by default. To change this, modify your csproj file to include this property:

<PropertyGroup>
  <IsPackable>true</IsPackable>
</PropertyGroup>

Note that as of now (2017) there isn't a good story for "library web projects" or web project packages that work for all scenarios you would want to use a NuGet package for. But this property will at least unblock producing a package.

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
0

I had the same issue with VS2022, looked at the documentation and noticed they "silently deprecated" the command.

You now should add the following in your .csproj file:

You then generate a package and copy it to the "right" folder by calling

dotnet msbuild -t:pack -property:Configuration=Release "ProjectFile.csproj"

Have a look at the link, the title is a bit confusing but there seemed to have been a change after With MSBuild 15.1+

Walter Verhoeven
  • 3,867
  • 27
  • 36