GitXplorerGitXplorer
M

GetPackFromProject

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
703e88b07408b49c984bd71b4c5cbb3a5f3bac60

Update SDK to .NET 9 (#11)

MMattKotsenas committed 2 months ago
Verified
4845d901aca979556fd43a96f505f655f8d5db6e

Also call Pack in GetPackFromProject_PackFor* (#10)

MMattKotsenas committed 2 months ago
Verified
44fe86f5d7b5d5c58a7fb2f367f17aa0e78f344a

Update MSTest source generator to test assembly attribute (#9)

MMattKotsenas committed 8 months ago
Verified
06775e0684af6246161073a4f38c59ef8ec53e57

Switch to MSTest (#8)

MMattKotsenas committed 8 months ago
Verified
26b0ef2050726fe02559b7fd4dfdd0444c89e472

Update Verify.Nupkg version and update baselines (#7)

MMattKotsenas committed 10 months ago
Verified
e41c90e9c93e295a20767235526c807248620c86

Remove Package NoTargets project and create package directly (#6)

MMattKotsenas committed 10 months ago

README

The README file for this repository.

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()