Skip to content

Commit 03d69cf

Browse files
committed
Sign the *.VSInsertionMetadata optprof package
1 parent 71b9db8 commit 03d69cf

File tree

8 files changed

+83
-50
lines changed

8 files changed

+83
-50
lines changed

Expand-Template.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ try {
105105
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
106106
git mv test/Library.Tests "test/$LibraryName.Tests"
107107
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
108+
git mv src/VSInsertionMetadata/Library.VSInsertionMetadata.proj "src/VSInsertionMetadata/$LibraryName.VSInsertionMetadata.proj"
109+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
108110

109111
# Refresh solution file both to update paths and give the projects unique GUIDs
110112
dotnet sln remove src/Library/Library.csproj
@@ -168,12 +170,6 @@ try {
168170
'LibraryName' = $LibraryName;
169171
}
170172

171-
Replace-Placeholders -Path "azure-pipelines/InsertionMetadataPackage.nuspec" -Replacements @{
172-
'LibraryName' = $LibraryName;
173-
}
174-
Replace-Placeholders -Path "azure-pipelines/artifacts/VSInsertion.ps1" -Replacements @{
175-
'LibraryName' = $LibraryName;
176-
}
177173
Replace-Placeholders -Path "azure-pipelines/OptProf.yml" -Replacements @{
178174
'LibraryName' = $LibraryName;
179175
}

azure-pipelines/InsertionMetadataPackage.nuspec

Lines changed: 0 additions & 17 deletions
This file was deleted.

azure-pipelines/artifacts/VSInsertion.ps1

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,7 @@ $result = @{
2929

3030
if ($env:IsOptProf) {
3131
$VSRepoPackages = "$RepoRoot/bin/Packages/$BuildConfiguration/VSRepo"
32-
33-
$ArtifactBasePath = "$RepoRoot\obj\_artifacts"
34-
$ArtifactPath = "$ArtifactBasePath\VSInsertion"
35-
if (-not (Test-Path $ArtifactPath)) { New-Item -ItemType Directory -Path $ArtifactPath | Out-Null }
36-
37-
$profilingInputs = [xml](Get-Content -Path "$PSScriptRoot\..\ProfilingInputs.props")
38-
$profilingInputs.Project.ItemGroup.TestStore.Include = "vstsdrop:" + (& "$PSScriptRoot\..\variables\ProfilingInputsDropName.ps1")
39-
$profilingInputs.Save("$ArtifactPath\ProfilingInputs.props")
40-
41-
$InsertionMetadataVersion = $(dotnet tool run nbgv get-version -p "$RepoRoot\src" -f json | ConvertFrom-Json).NuGetPackageVersion
42-
if ($env:BUILD_BUILDID) {
43-
# We must ensure unique versions for the insertion metadata package so
44-
# it can contain information that is unique to this build.
45-
# In particular it includes the ProfilingInputsDropName, which contains the BuildId.
46-
# A non-unique package version here may collide with a prior run of this same commit,
47-
# ultimately resulting in a failure of the optprof run.
48-
$InsertionMetadataVersion += '.' + $env:BUILD_BUILDID
49-
}
50-
& (& "$PSScriptRoot\..\Get-NuGetTool.ps1") pack "$PSScriptRoot\..\InsertionMetadataPackage.nuspec" -OutputDirectory $VSRepoPackages -BasePath $ArtifactPath -Version $InsertionMetadataVersion | Out-Null
51-
if ($LASTEXITCODE -ne 0) {
52-
exit $LASTEXITCODE
53-
}
54-
55-
$result["$VSRepoPackages"] = (Get-ChildItem "$VSRepoPackages\LibraryName.VSInsertionMetadata.$InsertionMetadataVersion.nupkg");
32+
$result["$VSRepoPackages"] = (Get-ChildItem "$VSRepoPackages\*.VSInsertionMetadata.*.nupkg");
5633
}
5734

5835
$result

azure-pipelines/dotnet.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ steps:
1717
condition: and(succeeded(), ${{ parameters.RunTests }})
1818

1919
- ${{ if parameters.IsOptProf }}:
20-
# We have to artifically run this script so that the extra .nupkg is produced for variables/InsertPropsValues.ps1 to notice.
21-
- powershell: azure-pipelines\artifacts\VSInsertion.ps1
22-
displayName: 🔧 Prepare VSInsertion artifact
20+
- script: dotnet pack src\VSInsertionMetadata -c $(BuildConfiguration) -warnaserror /bl:"$(Build.ArtifactStagingDirectory)/build_logs/VSInsertion-Pack.binlog"
21+
displayName: 🔧 dotnet pack VSInsertionMetadata
2322

2423
- powershell: azure-pipelines/variables/_pipelines.ps1
2524
failOnStderr: true

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"version": "8.0.300",
44
"rollForward": "patch",
55
"allowPrerelease": false
6+
},
7+
"msbuild-sdks": {
8+
"Microsoft.Build.NoTargets": "3.7.56"
69
}
710
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.Build.NoTargets">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
5+
<PackageOutputPath>$(RepoRootPath)bin\Packages\$(Configuration)\VSRepo\</PackageOutputPath>
6+
<IncludeSymbols>false</IncludeSymbols>
7+
<EnableDefaultSignFiles>false</EnableDefaultSignFiles>
8+
<Description>Contains metadata for insertion into VS.</Description>
9+
</PropertyGroup>
10+
<Import Project="VSInsertionMetadata.targets" />
11+
</Project>
File renamed without changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<Project>
2+
<UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
3+
<ParameterGroup>
4+
<InputFilename ParameterType="System.String" Required="true" />
5+
<OutputFilename ParameterType="System.String" Required="true" />
6+
<MatchExpression ParameterType="System.String" Required="true" />
7+
<ReplacementText ParameterType="System.String" Required="true" />
8+
</ParameterGroup>
9+
<Task>
10+
<Using Namespace="System" />
11+
<Using Namespace="System.IO" />
12+
<Using Namespace="System.Text.RegularExpressions" />
13+
<Code Type="Fragment" Language="cs">
14+
<![CDATA[
15+
File.WriteAllText(
16+
OutputFilename,
17+
Regex.Replace(File.ReadAllText(InputFilename), MatchExpression, ReplacementText)
18+
);
19+
]]>
20+
</Code>
21+
</Task>
22+
</UsingTask>
23+
24+
<PropertyGroup>
25+
<TargetsForTfmSpecificContentInPackage>
26+
$(TargetsForTfmSpecificContentInPackage);
27+
SubstituteProfilingInputsMacro;
28+
SubstituteProfilingInputsMacroWarning;
29+
</TargetsForTfmSpecificContentInPackage>
30+
</PropertyGroup>
31+
32+
<Target Name="SubstituteProfilingInputsMacroWarning" Condition="'$(ProfilingInputsDropName)'==''">
33+
<Warning Text="The ProfilingInputsDropName msbuild property has not been set, and the OptProf will not contain accurate content."/>
34+
</Target>
35+
<Target Name="SubstituteProfilingInputsMacro" Condition="'$(ProfilingInputsDropName)'!=''">
36+
<ItemGroup>
37+
<ProfilingInputsSource Include="ProfilingInputs.props" />
38+
<ProfilingInputsTarget Include="$(IntermediateOutputPath)ProfilingInputs.props" />
39+
</ItemGroup>
40+
<ReplaceFileText
41+
Condition="'$(ProfilingInputsDropName)' != ''"
42+
InputFilename="@(ProfilingInputsSource)"
43+
OutputFilename="@(ProfilingInputsTarget)"
44+
MatchExpression="%TESTSTORE%"
45+
ReplacementText="vstsdrop:$(ProfilingInputsDropName)" />
46+
<ItemGroup>
47+
<TfmSpecificPackageFile Include="@(ProfilingInputsTarget)" PackagePath="InsertionVS/" />
48+
</ItemGroup>
49+
</Target>
50+
<Target Name="EnsureUniquePackageVersion"
51+
Condition="'$(Build_BuildId)' != ''"
52+
AfterTargets="GetBuildVersion">
53+
<!--
54+
We must ensure unique versions for the insertion metadata package so
55+
it can contain information that is unique to this build.
56+
In particular it includes the ProfilingInputsDropName, which contains the BuildId.
57+
A non-unique package version here may collide with a prior run of this same commit,
58+
ultimately resulting in a failure of the optprof run.
59+
-->
60+
<PropertyGroup>
61+
<PackageVersion>$(PackageVersion).$(Build_BuildId)</PackageVersion>
62+
</PropertyGroup>
63+
</Target>
64+
</Project>

0 commit comments

Comments
 (0)