6

With all dependencies added to the package.

I've tried multiple ways but it looks like I might have to get messy to do it, adding a nuspec file on its own is not sufficient because of the way in which dependencies are resolved.

To put this into perspective If I a package a .net framework project with a nuspec file and in the file point at the relevant output folder (for example bin\release) of a build I get everything I need.

My use case is to run some acceptance tests (out of process) in a CI pipeline. At this point I don't want to be accessing source control.

2 Answers 2

8

Take a look at NuGet.Build.Tasks.Pack

You can use a .nuspec file to pack your project if you reference at NuGet.Build.Tasks.Pack. I've done this to roll up multiple projects in my solution into one nuget package.

You can pack with dotnet.exe:

dotnet pack <path to .csproj file> /p:NuspecFile=<path to nuspec file> /p:NuspecProperties=<> /p:NuspecBasePath=<Base path>

Or MSBuild:

msbuild /t:pack <path to .csproj file> /p:NuspecFile=<path to nuspec file> /p:NuspecProperties=<> /p:NuspecBasePath=<Base path>

More details can be found here: https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#packing-using-a-nuspec

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

1 Comment

Ok I'll give this a whirl. Using dotnet publish (which is what I resorted to doesnt seem quite correct) but it works if I then pack this, but would be nicer as one step.
0

Ok so this is not a particularly unusual use case but with .NET framework nuget packaging there is no ceremony.

So I am deploying a package which has some test assemblies and all of the associated dependencies (assemblies and appsettings files) needed for successful exection by Nunit console runner

The solution we have come up with is use both DotNetCorePublish and OctoPack (As a convenience instead of nuget pack)

So DotNetCorePublish reconciles all 3rd party dependencies in place and creates a folder (named publish by default) with everything needed to execute any tests in there (so this is a Framework dependent deploy I have since learnt)

OctoPack then is configured to point to what we want to package. So, setting this to the relevant folder (using relevant wildcards/globs) pulls in everything we need. A nuspec file is created on the fly which is used to created the Nuget package.

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.