NugetBuildTargetsIntegrationTesting 2.0.1
dotnet add package NugetBuildTargetsIntegrationTesting --version 2.0.1
NuGet\Install-Package NugetBuildTargetsIntegrationTesting -Version 2.0.1
<PackageReference Include="NugetBuildTargetsIntegrationTesting" Version="2.0.1" />
<PackageVersion Include="NugetBuildTargetsIntegrationTesting" Version="2.0.1" />
<PackageReference Include="NugetBuildTargetsIntegrationTesting" />
paket add NugetBuildTargetsIntegrationTesting --version 2.0.1
#r "nuget: NugetBuildTargetsIntegrationTesting, 2.0.1"
#:package NugetBuildTargetsIntegrationTesting@2.0.1
#addin nuget:?package=NugetBuildTargetsIntegrationTesting&version=2.0.1
#tool nuget:?package=NugetBuildTargetsIntegrationTesting&version=2.0.1
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
In your tests create a field of DependentProjectBuilder.
CreateProject()
If required AddFiles -
AddFiles(IEnumerable<(string Contents, string RelativePath)> files);Add the proj file as a string -
AddProject(string projectContents, string relativePath);Add the nupkg to test -
AddNuPkg(string nuPkgPath);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=falseIBuildResult BuildWithMSBuild(string arguments = "");Default is
-restore -property:Configuration=Release -property:nodeReuse=falseIf 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\packagesit will be used otherwise internet connectivity is required.If you need to rebuild the return value of
BuildWithDotNetandBuildWithMSBuild,IBuildResult, hasIBuildResult 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 | Versions 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. |
-
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.