GetPackFromProject 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package GetPackFromProject --version 1.0.2                
NuGet\Install-Package GetPackFromProject -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GetPackFromProject" Version="1.0.2">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GetPackFromProject --version 1.0.2                
#r "nuget: GetPackFromProject, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GetPackFromProject as a Cake Addin
#addin nuget:?package=GetPackFromProject&version=1.0.2

// Install GetPackFromProject as a Cake Tool
#tool nuget:?package=GetPackFromProject&version=1.0.2                

Icon

GetPackFromProject

Build status Nuget Downloads

An MSBuild task / helper to simplify testing NuGet packages by automatically ensuring the latest package is built and placed in the output directory for test projects. To use, first install the package, then add the metadata AddPackageAsOutput=true to any <ProjectReference> items like this:

<ItemGroup>
  <ProjectReference Include="..\MyPackage\MyPackage.csproj" AddPackageAsOutput="true" />
</ItemGroup>

Adding that metadata will do a few things:

  1. Ensure the package is generated on every build

To avoid working with stale packages, the build will validate that any projects with this metadata have the GeneratePackageOnBuild property set (by default, a project only creates a package when you run the Pack target).

  1. Add the outputs of the pack operation (e.g. .nupkg and .nuspec files) as metadata on the <ProjectReference>

  2. Add all .nupkg files as <Content> items for your build

This ensures that the packages can be copied to your output directory for tests.

Finding the package in tests

Add this snippet to your unit tests to get the path to an output NuGet package:

FileInfo package = new(Assembly.GetExecutingAssembly().Location)
    .Directory!
    .GetFiles("NameOfNuGetPackageToTest*.nupkg")
    .OrderByDescending(f => f.LastWriteTimeUtc)
    .First()
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.10 144 11/23/2024
1.0.6 2,405 3/30/2024
1.0.4 84 3/27/2024
1.0.2 101 3/22/2024