diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index 68f8259274..00b1a0b56a 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -15,18 +15,4 @@ $(InnerBuildArgs) -c $(Configuration) - - - - - - - - - diff --git a/eng/source-build-patches/0001-Build-for-NET-6.patch b/eng/source-build-patches/0001-Build-for-NET-6.patch deleted file mode 100644 index 16993215da..0000000000 --- a/eng/source-build-patches/0001-Build-for-NET-6.patch +++ /dev/null @@ -1,48 +0,0 @@ -From cc24a98b1886861269afa3dae243f5eee63c70eb Mon Sep 17 00:00:00 2001 -From: Medeni Baykal <433724+Haplois@users.noreply.github.com> -Date: Thu, 17 Jun 2021 02:35:04 +0200 -Subject: [PATCH] Build for NET 6 - ---- - src/package/nuspec/TestPlatform.Build.nuspec | 6 +++--- - src/package/nuspec/TestPlatform.CLI.nuspec | 2 +- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/src/package/nuspec/TestPlatform.Build.nuspec b/src/package/nuspec/TestPlatform.Build.nuspec -index 3808b296..e70511ae 100644 ---- a/src/package/nuspec/TestPlatform.Build.nuspec -+++ b/src/package/nuspec/TestPlatform.Build.nuspec -@@ -20,16 +20,16 @@ - commit="$CommitId$" /> - - -- -+ - - - - - -- -+ - - -- -+ - - - -diff --git a/src/package/nuspec/TestPlatform.CLI.nuspec b/src/package/nuspec/TestPlatform.CLI.nuspec -index 0e72bf58..01b624c0 100644 ---- a/src/package/nuspec/TestPlatform.CLI.nuspec -+++ b/src/package/nuspec/TestPlatform.CLI.nuspec -@@ -29,6 +29,6 @@ - - - -- -+ - - -2.31.1.windows.1 - diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 947f74989e..94f6cd0198 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -800,8 +800,6 @@ function Create-NugetPackages "Microsoft.TestPlatform.AdapterUtilities.nuspec", "Microsoft.TestPlatform.nuspec", "Microsoft.TestPlatform.Portable.nuspec", - "TestPlatform.Build.nuspec", - "TestPlatform.CLI.nuspec", "TestPlatform.Extensions.TrxLogger.nuspec", "TestPlatform.ObjectModel.nuspec", "TestPlatform.TestHost.nuspec", @@ -809,13 +807,33 @@ function Create-NugetPackages "TestPlatform.Internal.Uwp.nuspec" ) - $targetFiles = @("Microsoft.CodeCoverage.targets") - $propFiles = @("Microsoft.NET.Test.Sdk.props", "Microsoft.CodeCoverage.props") - $contentDirs = @("netcoreapp", "netfx") + $projectFiles = @( + "Microsoft.TestPlatform.CLI.csproj", + "Microsoft.TestPlatform.Build.csproj" + ) + + $dependencies = @( + "TestPlatform.Build.nuspec", + "TestPlatform.CLI.nuspec", + + ## .target and .props Files + "Microsoft.NET.Test.Sdk.props", + "Microsoft.CodeCoverage.props", + "Microsoft.CodeCoverage.targets", + + ## Content Directories + "netcoreapp", + "netfx" + ) # Nuget pack analysis emits warnings if binaries are packaged as content. It is intentional for the below packages. - $skipAnalysis = @("TestPlatform.CLI.nuspec") - foreach ($item in $nuspecFiles + $targetFiles + $propFiles + $contentDirs) { + $skipAnalysis = @( + "TestPlatform.CLI.nuspec", + "Microsoft.TestPlatform.CLI.csproj" + ) + + + foreach ($item in $nuspecFiles + $projectFiles + $dependencies) { Copy-Item $tpNuspecDir\$item $stagingDir -Force -Recurse } @@ -840,6 +858,7 @@ function Create-NugetPackages # Call nuget pack on these components. $nugetExe = Join-Path $env:TP_PACKAGES_DIR -ChildPath "Nuget.CommandLine" | Join-Path -ChildPath $env:NUGET_EXE_Version | Join-Path -ChildPath "tools\NuGet.exe" + $dotnetExe = Get-DotNetPath # Pass Newtonsoft.Json version to nuget pack to keep the version consistent across all nuget packages. $JsonNetVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.JsonNetVersion @@ -869,6 +888,17 @@ function Create-NugetPackages Invoke-Exe $nugetExe -Arguments "pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version;JsonNetVersion=$JsonNetVersion;Runtime=$TPB_TargetRuntime;NetCoreTargetFramework=$TPB_TargetFrameworkCore20;FakesPackageDir=$FakesPackageDir;NetStandard10Framework=$TPB_TargetFrameworkNS10;NetStandard13Framework=$TPB_TargetFrameworkNS13;NetStandard20Framework=$TPB_TargetFrameworkNS20;Uap10Framework=$uap10Nuget;BranchName=$TPB_BRANCH;CommitId=$TPB_COMMIT $additionalArgs" } + foreach ($file in $projectFiles) { + $additionalArgs = "" + if ($skipAnalysis -contains $file) { + $additionalArgs = "-NoPackageAnalysis" + } + + Write-Host "Attempting to build package from '$file'." + Invoke-Exe $dotnetExe -Arguments "restore $stagingDir\$file" -CaptureOutput | Out-Null + Invoke-Exe $dotnetExe -Arguments "pack --no-build $stagingDir\$file -o $packageOutputDir -p:Version=$TPB_Version -p:BranchName=`"$TPB_BRANCH`" -p:CommitId=`"$TPB_COMMIT`" /bl:pack_$file.binlog" + } + # Verifies that expected number of files gets shipped in nuget packages. # Few nuspec uses wildcard characters. Verify-Nuget-Packages $packageOutputDir $TPB_Version diff --git a/scripts/build.sh b/scripts/build.sh index d6e2e6bf73..132902be2c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -151,6 +151,9 @@ TPB_Verbose=$VERBOSE TPB_EXTERNALS_VERSION=$(grep TestPlatformExternalsVersion $TP_ROOT_DIR/scripts/build/TestPlatform.Dependencies.props | head -1 | cut -d'>' -f2 | cut -d'<' -f1 || echo $VERSION) TPB_CC_EXTERNALS_VERSION=$(grep MicrosoftInternalCodeCoverageVersion $TP_ROOT_DIR/eng/Versions.props | head -1 | cut -d'>' -f2 | cut -d'<' -f1 || echo $VERSION) +TPB_BRANCH="$(git -C "." rev-parse --abbrev-ref HEAD 2>/dev/null)" || TPB_BRANCH="LOCALBRANCH" # detached HEAD +TPB_COMMIT="$(git -C "." rev-parse HEAD 2>/dev/null)" || TPB_COMMIT="LOCALBUILD" # detached HEAD + if [[ $TP_USE_REPO_API = 1 ]]; then TPB_TargetFrameworkCore="net6.0" fi @@ -508,18 +511,20 @@ function create_package() for i in ${projectFiles[@]}; do if [[ $TP_USE_REPO_API = 0 ]]; then - log "$dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version" + log "$dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version -p:BranchName=$TPB_BRANCH -p:CommitId=$TPB_COMMIT" - $dotnet restore $stagingDir/${i} \ - && $dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version /bl:pack_$i.binlog + $dotnet restore $stagingDir/${i} -p:Version=$TPB_Version -p:BranchName="$TPB_BRANCH" -p:CommitId="$TPB_COMMIT" -bl:pack_$i.binlog \ + && $dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version -p:BranchName="$TPB_BRANCH" -p:CommitId="$TPB_COMMIT" -bl:pack_$i.binlog else - log "$dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version (Source Build)" + log "$dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version -p:BranchName=$TPB_BRANCH -p:CommitId=$TPB_COMMIT -p:DotNetBuildFromSource=true (Source Build)" - $dotnet restore $stagingDir/${i} \ - && $dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version /bl:pack_$i.binlog -p:DotNetBuildFromSource=true + $dotnet restore $stagingDir/${i} -p:Version=$TPB_Version -bl:restore_$i.binlog -p:DotNetBuildFromSource=true -p:BranchName="$TPB_BRANCH" -p:CommitId="$TPB_COMMIT" \ + && $dotnet pack --no-build $stagingDir/${i} -o $packageOutputDir -p:Version=$TPB_Version -bl:pack_$i.binlog -p:DotNetBuildFromSource=true -p:BranchName="$TPB_BRANCH" -p:CommitId="$TPB_COMMIT" fi done + + log "Create-NugetPackages: Elapsed $(( SECONDS - start ))s." } diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/Microsoft.TestPlatform.AdapterUtilities.csproj b/src/Microsoft.TestPlatform.AdapterUtilities/Microsoft.TestPlatform.AdapterUtilities.csproj index e3c9696e76..1f918f8c14 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/Microsoft.TestPlatform.AdapterUtilities.csproj +++ b/src/Microsoft.TestPlatform.AdapterUtilities/Microsoft.TestPlatform.AdapterUtilities.csproj @@ -46,7 +46,7 @@ - + diff --git a/src/package/external/external.csproj b/src/package/external/external.csproj index 3d9ecdca1f..0331d5a308 100644 --- a/src/package/external/external.csproj +++ b/src/package/external/external.csproj @@ -41,8 +41,8 @@ + - diff --git a/src/package/nuspec/Microsoft.TestPlatform.Build.csproj b/src/package/nuspec/Microsoft.TestPlatform.Build.csproj index 038fbf8920..6f3480e8ab 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.Build.csproj +++ b/src/package/nuspec/Microsoft.TestPlatform.Build.csproj @@ -1,10 +1,11 @@ Exe - netcoreapp1.0 + netstandard2.0 + net6.0 false TestPlatform.Build.nuspec - version=$(Version) + BranchName=$(BranchName);CommitId=$(CommitId);Version=$(Version);TargetFramework=$(TargetFramework) false diff --git a/src/package/nuspec/Microsoft.TestPlatform.CLI.csproj b/src/package/nuspec/Microsoft.TestPlatform.CLI.csproj index 29198ba2f3..b74d7ba0a6 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.CLI.csproj +++ b/src/package/nuspec/Microsoft.TestPlatform.CLI.csproj @@ -1,10 +1,11 @@ Exe - netcoreapp1.0 + netcoreapp2.1 + net6.0 false TestPlatform.CLI.nuspec - version=$(Version) + BranchName=$(BranchName);CommitId=$(CommitId);Version=$(Version);TargetFramework=$(TargetFramework) false diff --git a/src/package/nuspec/TestPlatform.Build.nuspec b/src/package/nuspec/TestPlatform.Build.nuspec index 3808b2965f..b1fa93aa3a 100644 --- a/src/package/nuspec/TestPlatform.Build.nuspec +++ b/src/package/nuspec/TestPlatform.Build.nuspec @@ -20,16 +20,16 @@ commit="$CommitId$" /> - + - + - + diff --git a/src/package/nuspec/TestPlatform.CLI.nuspec b/src/package/nuspec/TestPlatform.CLI.nuspec index 0e72bf5885..e3d1c20172 100644 --- a/src/package/nuspec/TestPlatform.CLI.nuspec +++ b/src/package/nuspec/TestPlatform.CLI.nuspec @@ -29,6 +29,6 @@ - + diff --git a/src/testhost.x86/testhost.x86.csproj b/src/testhost.x86/testhost.x86.csproj index 06e2ad30a7..b7912ff95f 100644 --- a/src/testhost.x86/testhost.x86.csproj +++ b/src/testhost.x86/testhost.x86.csproj @@ -44,7 +44,7 @@ - + diff --git a/src/testhost/testhost.csproj b/src/testhost/testhost.csproj index cd8477bd59..8eacb315b1 100644 --- a/src/testhost/testhost.csproj +++ b/src/testhost/testhost.csproj @@ -45,7 +45,7 @@ - + diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/Microsoft.TestPlatform.Utilities.UnitTests.csproj b/test/Microsoft.TestPlatform.Utilities.UnitTests/Microsoft.TestPlatform.Utilities.UnitTests.csproj index b1ada1e9c5..1cbdc695ff 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/Microsoft.TestPlatform.Utilities.UnitTests.csproj +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/Microsoft.TestPlatform.Utilities.UnitTests.csproj @@ -20,7 +20,7 @@ 1.0.3 - +