BarYaron
BarYaron

Reputation: 87

Packing the Project didn't create nupkg file (Visual Studio 2022)

I followed this guide: https://learn.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio?tabs=netcore-cli for creating a nupkg file locally for my project (until run the pack command).

Steps to reproduce:

  1. Created a project (and added the code) - net 5.0

  2. Right Click on the project and then left click on pack

  3. Message from the build: ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

But, my nupkg file wasn't created, what could cause this issue?

Update: I tried cleaning the solution then packing it again and it still didn't help.

In addition, I tried to run it with:

donet pack 

and I got these message in verbose mode:

1>Project "PROJECT_PATH" on node 1 (Restore target(s)). 1>_GetAllRestoreProjectPathItems: Determining projects to restore... Restore: Committing restore... Assets file has not changed. Skipping assets file writing. Path: PROJECT_PATH\obj\project.assets.json Restored PROJECT_PATH\PROJECT.csproj (in 39 ms).

NuGet Config files used: NUGET_CONFIG_PATH

Feeds used: https://api.nuget.org/v3/index.json

MY_PATH\NuGetPackages\

PROJECT_PATH All projects are up-to-date for restore. 1>Done Building Project "PROJECT_PATH\PROJECT.csproj" (Restore target(s)).

Upvotes: 0

Views: 1586

Answers (3)

user22047698
user22047698

Reputation: 1

Add line in your csproj file directly as below

<GeneratePackageOnBuild>True</GeneratePackageOnBuild>

Or go to the project properties --> packages --> and then enable the option "Produce a package file during build operations"

Project properties for packages

Upvotes: 0

Samidjo
Samidjo

Reputation: 2355

Make sure you have no test libraries or packages in your project like:

  • NUnit
  • XUnit
  • Microsoft.NET.Test.Sdk
  • ..

After that, if the small icon besides the name of the project is "C#", you're good to go.

Please make a separate project for your testing.

Upvotes: 1

BarYaron
BarYaron

Reputation: 87

Problem Solved:

Xunit preventing from packing the Project,

In order to pack a project with Xunit, you need to add to the csproj file the:

<IsPackable>true</IsPackable>

Upvotes: 4

Related Questions