NugetBuildTargetsIntegrationTesting 2.0.1

dotnet add package NugetBuildTargetsIntegrationTesting --version 2.0.1
                    
NuGet\Install-Package NugetBuildTargetsIntegrationTesting -Version 2.0.1
                    
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="NugetBuildTargetsIntegrationTesting" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NugetBuildTargetsIntegrationTesting" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="NugetBuildTargetsIntegrationTesting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NugetBuildTargetsIntegrationTesting --version 2.0.1
                    
#r "nuget: NugetBuildTargetsIntegrationTesting, 2.0.1"
                    
#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.
#:package NugetBuildTargetsIntegrationTesting@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NugetBuildTargetsIntegrationTesting&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=NugetBuildTargetsIntegrationTesting&version=2.0.1
                    
Install as a Cake Tool

DependentProjectBuilder

Overview

DependentProjectBuilder streamlines integration testing for NuGet packages providing build targets. It creates a temporary nuget environment with temporary dependent projects that are built for you, enabling custom targets to be run and their behaviour asserted.

Command requirements

The NuGet CLI add command is used.

If you BuildWithDotNet then the .Net CLI build command is used.

If you BuildWithMSBuild then msbuild.exe is used.

Each of these are expected to be on Path.

If this is not the case then the DependentProjectBuilder constructor can be passed a CommandPaths object.

Usage

  1. In your tests create a field of DependentProjectBuilder.

  2. CreateProject()

  3. If required AddFiles - AddFiles(IEnumerable<(string Contents, string RelativePath)> files);

  4. Add the proj file as a string - AddProject(string projectContents, string relativePath);

  5. Add the nupkg to test - AddNuPkg(string nuPkgPath);

  6. Build - if required specify your own arguments that will be appended to the generated project file path

    IBuildResult BuildWithDotNet(string arguments = "");

    Default is - -c Release -property:nodeReuse=false

    IBuildResult BuildWithMSBuild(string arguments = "");

    Default is -restore -property:Configuration=Release -property:nodeReuse=false

    If your task is not working you may want to add the binary logger switch for viewing with the MSBuild Structured Log Viewer

    BuildWithMSBuild sdk style The package Microsoft.Net.Sdk.Compilers.Toolset may be rquired.

    This package is automatically downloaded when your MSBuild version does not match your SDK version.

    If you already have the corresponding version in {userprofile}\.nuget\packages it will be used otherwise internet connectivity is required.

  7. If you need to rebuild the return value of BuildWithDotNet and BuildWithMSBuild, IBuildResult, has

    IBuildResult AddFiles(IEnumerable<(string Contents, string RelativePath)> files);

    void Rebuild(string? args = null);

    Rebuild will use the command that you chose before. If you do not specify args then it will use the same args from before.

Failing build

The IBuildResult has the following properties

    string StandardError { get; }

    string ErrorAndOutput { get; }

    string StandardOutput { get; }

    bool Passed { get; }

Temp directories

The IBuildResult has the properties

    DirectoryInfo ContainingDirectory { get; }

    DirectoryInfo ProjectDirectory { get; }

Use DependentProjectBuilder TearDown() in a one time tear down to remove all temp directories.

NUnitTest

See the IntegrationTest project in the GitHub repository for a simple test that uses this setup class.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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
2.0.1 222 10/22/2025
2.0.0 207 10/22/2025
1.0.0 225 9/24/2025