2

I am struggling to get dotnet pack to generate a nuget package from a .NetCore2.1 project.

When I run dotnet pack from the cmd line the project is restored but then it goes no further.

Is this a limitation? I am struggling to find anything valuable online.

I am using AspNetCore.Mvc so moving to standard is not an option...

Thanks.

2
  • 1
    Assuming you read the guide, what was the commandline you ran and what exactly happened (output)?. What did you expect to happen instead? Commented Oct 17, 2018 at 12:11
  • I managed to solve this with the help of Microsoft. Their response: What kind of project is it? A: xUnit ASP.NET Core projects aren't packable by default, since you should use Razor class libraries instead. (Which you could work around by setting <IsPackable>true</IsPackable> inside a <PropertyGroup>) It seems to be only relevant to NetCore xUnit projects - github.com/xunit/xunit/issues/1520 Commented Oct 17, 2018 at 12:41

2 Answers 2

5

ASP.NET Core and Xunit / test projects aren't packable by default. To create a package containing View assets, create a Razor class library instead. Or create a class library project for .NET Core.

Alternatively, you can add this to your csproj file to force the project to be packable:

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

Do not that these defaults have been put in place to prevent packages from creating unwanted side-effects or not behaving as expected so use with caution.

Sign up to request clarification or add additional context in comments.

Comments

0

As Martin says above, test projects are not packable, in my case, we had an unneeded reference to

Microsoft.NET.Test.Sdk 

Upon removing this reference I could package the project

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.