Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nuspec project target frameworks for source-build #3285

Merged
merged 11 commits into from
Mar 9, 2022
14 changes: 0 additions & 14 deletions eng/SourceBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,4 @@
<InnerBuildArgs>$(InnerBuildArgs) -c $(Configuration)</InnerBuildArgs>
</PropertyGroup>

<!-- TODO: Remove once all patches have been removed. -->
<Target Name="ApplySourceBuildPatchFiles"
AfterTargets="PrepareInnerSourceBuildRepoRoot"
BeforeTargets="RunInnerSourceBuildCommand">
<ItemGroup>
<SourceBuildPatchFile Include="$(RepositoryEngineeringDir)source-build-patches\*.patch" />
</ItemGroup>

<Exec
Command="git --work-tree=$(InnerSourceBuildRepoRoot) apply --ignore-whitespace --whitespace=nowarn &quot;%(SourceBuildPatchFile.FullPath)&quot;"
WorkingDirectory="$(InnerSourceBuildRepoRoot)"
Condition="'@(SourceBuildPatchFile)' != ''" />
</Target>

</Project>
48 changes: 0 additions & 48 deletions eng/source-build-patches/0001-Build-for-NET-6.patch

This file was deleted.

44 changes: 37 additions & 7 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -800,22 +800,40 @@ 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",
"TestPlatform.TranslationLayer.nuspec"
"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
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<!-- / CVE-2018-8356 mitigation -->
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true'">
<!-- CVE-2019-0657 mitigation -->
<PackageReference Include="System.Private.Uri" Version="$(SystemUriVersion)" />
<!-- / CVE-2019-0657 mitigation -->
Expand Down
2 changes: 1 addition & 1 deletion src/package/external/external.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<PackageReference Include="Microsoft.DiaSymReader.Pdb2Pdb" Version="1.1.0-beta2-21075-01" PrivateAssets="All" />
<PackageReference Include="Microsoft.Internal.TestPlatform.Remote" Version="$(TestPlatformRemoteExternalsVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Internal.TestPlatform.Extensions" Version="$(TestPlatformExternalsVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Coverage.IO" Version="$(MicrosoftInternalCodeCoverageVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.TraceDataCollector" Version="$(MicrosoftInternalCodeCoverageVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Coverage.IO" Version="$(MicrosoftInternalCodeCoverageVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Internal.CodeCoverage" Version="$(MicrosoftInternalCodeCoverageVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.QualityTools" Version="$(TestPlatformExternalsVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.QualityTools.DataCollectors" Version="$(TestPlatformExternalsVersion)" PrivateAssets="All" />
Expand Down
5 changes: 3 additions & 2 deletions src/package/nuspec/Microsoft.TestPlatform.Build.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework Condition=" '$(DotNetBuildFromSource)' != 'true' ">netstandard2.0</TargetFramework>
<TargetFramework Condition=" '$(DotNetBuildFromSource)' == 'true' ">net6.0</TargetFramework>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<NuspecFile>TestPlatform.Build.nuspec</NuspecFile>
<NuspecProperties>version=$(Version)</NuspecProperties>
<NuspecProperties>BranchName=$(BranchName);CommitId=$(CommitId);Version=$(Version);TargetFramework=$(TargetFramework)</NuspecProperties>

<!-- Don't include the output.dll and output.runtimeconfig.json files in nuget package -->
<IncludeBuildOutput>false</IncludeBuildOutput>
Expand Down
5 changes: 3 additions & 2 deletions src/package/nuspec/Microsoft.TestPlatform.CLI.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework Condition=" '$(DotNetBuildFromSource)' != 'true' ">netcoreapp2.1</TargetFramework>
<TargetFramework Condition=" '$(DotNetBuildFromSource)' == 'true' ">net6.0</TargetFramework>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<NuspecFile>TestPlatform.CLI.nuspec</NuspecFile>
<NuspecProperties>version=$(Version)</NuspecProperties>
<NuspecProperties>BranchName=$(BranchName);CommitId=$(CommitId);Version=$(Version);TargetFramework=$(TargetFramework)</NuspecProperties>

<!-- Don't include the output.dll and output.runtimeconfig.json files in nuget package -->
<IncludeBuildOutput>false</IncludeBuildOutput>
Expand Down
6 changes: 3 additions & 3 deletions src/package/nuspec/TestPlatform.Build.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
commit="$CommitId$" />

<dependencies>
<group targetFramework="netstandard2.0"></group>
<group targetFramework="$TargetFramework$"></group>
</dependencies>
</metadata>
<files>
<file src="Icon.png" target="" />
<file src="licenses\LICENSE_NET.txt" target="" />
<file src="Microsoft.TestPlatform.Build\netstandard2.0\Microsoft.TestPlatform.targets" target="runtimes\any\native" />
<file src="Microsoft.TestPlatform.Build\$TargetFramework$\Microsoft.TestPlatform.targets" target="runtimes\any\native" />

<!-- Add localized resources -->
<file src="Microsoft.TestPlatform.Build\netstandard2.0\**\*.dll" target="lib\netstandard2.0" />
<file src="Microsoft.TestPlatform.Build\$TargetFramework$\**\*.dll" target="lib\$TargetFramework$" />

</files>
</package>
2 changes: 1 addition & 1 deletion src/package/nuspec/TestPlatform.CLI.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
<!-- Add a third party notice file -->
<file src="ThirdPartyNotices.txt" target="" />

<file src="netcoreapp2.1\**\*.*" exclude="**\*.pdb" target="contentFiles\any\netcoreapp2.1" />
<file src="$TargetFramework$\**\*.*" exclude="**\*.pdb" target="contentFiles\any\$TargetFramework$" />
</files>
</package>
2 changes: 1 addition & 1 deletion src/testhost.x86/testhost.x86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ProjectReference>

<!-- CVE-2019-0657, CVE-2019-0980 and CVE-2019-0981 mitigation -->
<PackageReference Include="System.Private.Uri" Version="$(SystemUriVersion)" />
<PackageReference Include="System.Private.Uri" Version="$(SystemUriVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'"/>
<PackageReference Include="Microsoft.NETCore.Targets" Version="1.1.4" Condition=" $(TargetFramework.StartsWith('net4')) OR '$(TargetFramework)' == 'netcoreapp1.0'" />
<!-- CVE-2019-0657, CVE-2019-0980 and CVE-2019-0981 mitigation -->
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/testhost/testhost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</ProjectReference>

<!-- CVE-2019-0657, CVE-2019-0980 and CVE-2019-0981 mitigation -->
<PackageReference Include="System.Private.Uri" Version="$(SystemUriVersion)" />
<PackageReference Include="System.Private.Uri" Version="$(SystemUriVersion)" Condition="'$(DotNetBuildFromSource)' != 'true'"/>
<PackageReference Include="Microsoft.NETCore.Targets" Version="1.1.4" Condition=" $(TargetFramework.StartsWith('net4')) OR '$(TargetFramework)' == 'netcoreapp1.0'" />
<!-- CVE-2019-0657, CVE-2019-0980 and CVE-2019-0981 mitigation -->
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="Microsoft.CodeCoverage">
<Version>1.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Coverage.IO" Version="17.0.0-beta.21465.2" />
<PackageReference Include="Microsoft.VisualStudio.Coverage.IO" Version="17.0.0-beta.21465.2" Condition="'$(DotNetBuildFromSource)' != 'true'"/>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System.Runtime" />
Expand Down