Skip to content

Commit 3926ef1

Browse files
authored
Merge pull request #877 from dotnet-maestro-bot/merge/release/2.1-to-release/2.2
[automated] Merge branch 'release/2.1' => 'release/2.2'
2 parents 320aba5 + 3109126 commit 3926ef1

File tree

10 files changed

+144
-19
lines changed

10 files changed

+144
-19
lines changed

.vsts.pipelines/builds/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
parameters:
1111
job: centos71
1212
imageName: microsoft/dotnet-buildtools-prereqs:centos-7-b46d863-20180719033416
13+
reportPrebuiltLeaks: true
1314
matrix:
1415
Production: {}
1516
Online: { type: Online }

.vsts.pipelines/jobs/ci-linux.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ parameters:
55
pool:
66
name: Hosted Ubuntu 1604
77
imageName: null
8+
reportPrebuiltLeaks: false
89

910
jobs:
1011
- job: ${{ parameters.job }}
@@ -28,6 +29,7 @@ jobs:
2829
docker.tb.work: -w /tb
2930
dropDirectory: $(stagingDirectory)/drop
3031
imageName: ${{ parameters.imageName }}
32+
reportPrebuiltLeaks: ${{ parameters.reportPrebuiltLeaks }}
3133
rootDirectory: $(Build.SourcesDirectory)/..
3234
stagingDirectory: $(rootDirectory)/sb/staging
3335
tarballName: tarball_$(Build.BuildId)
@@ -68,7 +70,7 @@ jobs:
6870
displayName: Build source-build
6971
timeoutInMinutes: 120
7072
71-
# Run smoke tests.
73+
# Run smoke tests. This is needed even in tarball legs to create the smoke-test-prereqs archive.
7274
- script: |
7375
set -x
7476
df -h
@@ -82,9 +84,13 @@ jobs:
8284
- script: |
8385
set -x
8486
df -h
87+
args="--skip-build"
88+
if [ "$(reportPrebuiltLeaks)" = "true" ]; then
89+
args="$args --enable-leak-detection"
90+
fi
8591
$(docker.run) $(docker.tb.map) $(docker.src.map) $(docker.src.work) $(imageName) ./build-source-tarball.sh \
8692
"/tb/$(tarballName)" \
87-
--skip-build
93+
$args
8894
displayName: Create tarball
8995
condition: and(succeeded(), eq(variables['sb.tarball'], true))
9096
@@ -114,10 +120,15 @@ jobs:
114120
if [ "$(sb.tarballOffline)" = "true" ]; then
115121
networkArg="--network=none"
116122
fi
123+
poisonArg=
124+
if [ "$(sb.tarball)" != "true" ]; then
125+
poisonArg="/p:EnablePoison=true"
126+
fi
117127
$(docker.run) $(docker.tb.map) $(docker.tb.work) $networkArg $(imageName) "$(tarballName)/build.sh" \
118128
/p:Configuration=$(sb.configuration) \
119129
/p:PortableBuild=$(sb.portable) \
120-
/p:FailOnPrebuiltBaselineError=true
130+
/p:FailOnPrebuiltBaselineError=true \
131+
$poisonArg
121132
displayName: Build tarball
122133
timeoutInMinutes: 120
123134
condition: and(succeeded(), eq(variables['sb.tarball'], true))
@@ -195,6 +206,15 @@ jobs:
195206
ArtifactName: Tarball $(artifactName)
196207
ArtifactType: Container
197208

209+
# Publish prebuilt report data to blob storage.
210+
- template: ../steps/publish-prebuilt-data-sh.yml
211+
parameters:
212+
relativeBlobPath: prebuilt-data/$(Build.SourceBranchName)/latest/$(artifactName)
213+
# Also publish per-build data to a unique location for future use.
214+
- template: ../steps/publish-prebuilt-data-sh.yml
215+
parameters:
216+
relativeBlobPath: prebuilt-data/$(Build.SourceBranchName)/rolling/$(Build.SourceVersion)/$(Build.BuildNumber)/$(Build.DefinitionName)/$(artifactName)
217+
198218
# Clean up (very large) working directory. root owner makes it difficult for others to remove.
199219
- script: $(docker.run) $(docker.root.map) $(imageName) bash -c 'rm -rf /root/sb'
200220
displayName: Clean sb directory

.vsts.pipelines/jobs/ci-osx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
timeoutInMinutes: 240
1414
variables:
1515
# Prefix to distinguish artifacts from different legs.
16-
artifactName: ${{ format('$(type) {0}', parameters.job) }}
16+
artifactName: ${{ format('{0} $(type)', parameters.job) }}
1717
logsDirectory: $(Build.ArtifactStagingDirectory)/logs
1818
SOURCE_BUILD_SKIP_SUBMODULE_CHECK: true
1919
# Default type, can be overridden by matrix legs.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
parameters:
2+
relativeBlobPath: ''
3+
4+
steps:
5+
- script: |
6+
set -x
7+
# Publish tarball's prebuilt data. Use ./build.sh from production build.
8+
$(docker.run) $(docker.tb.map) $(docker.src.map) $(docker.src.work) $(imageName) ./build.sh \
9+
/t:PublishPrebuiltReportData \
10+
/p:ProjectDir=/tb/$(tarballName)/ \
11+
"/p:RelativeBlobPath=$relativeBlobPath" \
12+
/p:ContainerName=$(publish.blobStorage.container) \
13+
/p:AzureAccountName=$(publish.blobStorage.account) \
14+
/p:AzureAccessToken=$(publish.blobStorage.accessToken) \
15+
/clp:v=D
16+
displayName: ${{ format('Publish prebuilt report data ({0})', parameters.relativeBlobPath) }}
17+
env:
18+
relativeBlobPath: ${{ parameters.relativeBlobPath }}
19+
condition: and(succeeded(), ne(variables['publish.blobStorage.accessToken'], ''), eq(variables['sb.tarball'], true))

build.proj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,30 @@
137137
EnvironmentVariables="prodConBlobFeedUrl=$(ProdConBlobFeedUrl)" />
138138
</Target>
139139

140+
<UsingTask AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll" TaskName="UploadToAzure" />
141+
142+
<Target Name="PublishPrebuiltReportData">
143+
<Error Text="RelativeBlobPath must be set to a non-empty string." Condition="'$(RelativeBlobPath)' == ''" />
144+
<Error Text="ContainerName must be set to a non-empty string." Condition="'$(ContainerName)' == ''" />
145+
<Error Text="AzureAccountName must be set to a non-empty string." Condition="'$(AzureAccountName)' == ''" />
146+
<Error Text="AzureAccessToken must be set to a non-empty string." Condition="'$(AzureAccessToken)' == ''" />
147+
148+
<ItemGroup>
149+
<ItemsToPublish Include="$(PackageReportDir)*.xml" />
150+
<ItemsToPublish>
151+
<RelativeBlobPath>$(RelativeBlobPath)/%(Filename)%(Extension)</RelativeBlobPath>
152+
</ItemsToPublish>
153+
</ItemGroup>
154+
155+
<Message Text="Uploading files to '$(AzureAccountName)' blob storage at $(ContainerName)/$(RelativeBlobPath)" />
156+
157+
<UploadToAzure AccountName="$(AzureAccountName)"
158+
AccountKey="$(AzureAccessToken)"
159+
ContainerName="$(ContainerName)"
160+
Items="@(ItemsToPublish)"
161+
Overwrite="true" />
162+
</Target>
163+
140164
<Import Project="$(ProjectDir)dependencies.targets" />
141165

142166
<Import Project="$(ToolsDir)VersionTools.targets" />

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ SDKPATH="$CLIPATH/sdk/$SDK_VERSION"
2626

2727
set -x
2828

29-
$CLIPATH/dotnet $SDKPATH/MSBuild.dll $SCRIPT_ROOT/build.proj /flp:v=diag /clp:v=m "$@"
29+
$CLIPATH/dotnet $SDKPATH/MSBuild.dll $SCRIPT_ROOT/build.proj /bl /flp:v=diag /clp:v=m "$@"
3030

repos/application-insights.proj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))/dir.props" />
44
<PropertyGroup>
5-
<PackagesOutput>$(SubmoduleDirectory)/bin/$(Configuration)</PackagesOutput>
5+
<PackagesOutput>$(ProjectDirectory)/bin/$(Configuration)</PackagesOutput>
66
<RepoApiImplemented>false</RepoApiImplemented>
77
<OrchestratedManifestBuildName>N/A</OrchestratedManifestBuildName>
88
</PropertyGroup>
@@ -13,6 +13,9 @@
1313
<PropertyGroup>
1414
<BuildCommandArgs>$(ProjectDirectory)/Microsoft.ApplicationInsights.csproj</BuildCommandArgs>
1515
<BuildCommandArgs>$(BuildCommandArgs) /p:Configuration=$(Configuration)</BuildCommandArgs>
16+
<!-- Re-assign EnlistmentRoot property so output directories end up under src/application-insights -->
17+
<BuildCommandArgs>$(BuildCommandArgs) /p:EnlistmentRoot=$(ProjectDirectory)/src</BuildCommandArgs>
18+
<BuildCommandArgs>$(BuildCommandArgs) /p:RelativeOutputPathBase=</BuildCommandArgs>
1619
<BuildCommandArgs>$(BuildCommandArgs) $(RedirectRepoOutputToLog)</BuildCommandArgs>
1720
</PropertyGroup>
1821

repos/dir.targets

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,15 @@
189189
<Output TaskParameter="PackageInfoItems" ItemName="_PreviouslySourceBuiltPackageInfos" />
190190
</ReadNuGetPackageInfos>
191191

192+
<ItemGroup>
193+
<_KnownOriginPackagePaths Include="$(PrebuiltSourceBuiltPackagesPath)*.nupkg" />
194+
<_KnownOriginPackagePaths Include="$(PrebuiltPackagesPath)*.nupkg" />
195+
<_KnownOriginPackagePaths Include="$(ReferencePackagesDir)*.nupkg" />
196+
</ItemGroup>
197+
192198
<GetSourceBuiltNupkgCacheConflicts SourceBuiltPackageInfos="@(_PreviouslySourceBuiltPackageInfos)"
193-
PackageCacheDir="$(PackagesDir)">
199+
PackageCacheDir="$(PackagesDir)"
200+
KnownOriginPackagePaths="@(_KnownOriginPackagePaths)">
194201
<Output TaskParameter="ConflictingPackageInfos" ItemName="ConflictingPackageInfos" />
195202
</GetSourceBuiltNupkgCacheConflicts>
196203
</Target>
@@ -213,7 +220,8 @@
213220
<WriteUsageReports DataFile="$(_ReportDataFile)"
214221
OutputDirectory="$(_ReportDir)" />
215222

216-
<Warning Text="Detected package id/version(s) in the cache that were source-built, but contents don't match. They were probably downloaded. See $(_ReportDir) for usage details. @(ConflictingPackageInfos->'%(PackageId) %(PackageVersion)', ', ')" />
223+
<Warning Text="Detected packages in the cache that should be source-built, but contents don't match. See $(_ReportDir) for usage details:" />
224+
<Warning Text="%(ConflictingPackageInfos.PackageId)/%(ConflictingPackageInfos.PackageVersion) : %(ConflictingPackageInfos.WarningMessage)" />
217225
</Target>
218226

219227
<Target Name="CreateRestoreSourceProps"

support/tarball/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export NUGET_PACKAGES="$SCRIPT_ROOT/packages/"
1414
MSBUILD_ARGUMENTS=("/p:OfflineBuild=true" "/flp:v=detailed")
1515

1616
echo "Rebuild reference assemblies"
17-
$CLI_ROOT/dotnet $CLI_ROOT/sdk/$CLI_VERSION/MSBuild.dll $SCRIPT_ROOT/tools-local/init-build.proj /t:BuildReferenceAssemblies ${MSBUILD_ARGUMENTS[@]} "$@"
17+
$CLI_ROOT/dotnet $CLI_ROOT/sdk/$CLI_VERSION/MSBuild.dll /bl:initBuildReferenceAssemblies.binlog $SCRIPT_ROOT/tools-local/init-build.proj /t:BuildReferenceAssemblies ${MSBUILD_ARGUMENTS[@]} "$@"
1818

1919
echo "Expanding BuildTools dependencies into packages directory..."
2020
# init-tools tries to copy from its script directory to Tools, which in this case is a copy to
@@ -38,5 +38,5 @@ REF_PACKAGE_SOURCE="$SCRIPT_ROOT/reference-packages/packages"
3838
exit 1
3939
)
4040

41-
$CLI_ROOT/dotnet $CLI_ROOT/sdk/$CLI_VERSION/MSBuild.dll $SCRIPT_ROOT/tools-local/init-build.proj /t:WriteDynamicPropsToStaticPropsFiles /p:GeneratingStaticPropertiesFile=true ${MSBUILD_ARGUMENTS[@]} "$@"
42-
$CLI_ROOT/dotnet $CLI_ROOT/sdk/$CLI_VERSION/MSBuild.dll $SCRIPT_ROOT/build.proj ${MSBUILD_ARGUMENTS[@]} "$@"
41+
$CLI_ROOT/dotnet $CLI_ROOT/sdk/$CLI_VERSION/MSBuild.dll /bl:initWriteDynamicPropsToStaticPropsFiles.binlog $SCRIPT_ROOT/tools-local/init-build.proj /t:WriteDynamicPropsToStaticPropsFiles /p:GeneratingStaticPropertiesFile=true ${MSBUILD_ARGUMENTS[@]} "$@"
42+
$CLI_ROOT/dotnet $CLI_ROOT/sdk/$CLI_VERSION/MSBuild.dll /bl:build.binlog $SCRIPT_ROOT/build.proj ${MSBUILD_ARGUMENTS[@]} "$@"

tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks/GetSourceBuiltNupkgCacheConflicts.cs

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
using Microsoft.Build.Framework;
66
using Microsoft.Build.Utilities;
7+
using NuGet.Packaging.Core;
8+
using NuGet.Versioning;
79
using System;
810
using System.IO;
911
using System.Linq;
@@ -40,13 +42,33 @@ public class GetSourceBuiltNupkgCacheConflicts : Task
4042
[Required]
4143
public string PackageCacheDir { get; set; }
4244

45+
/// <summary>
46+
/// Paths to packages to compare against when conflicts are detected. Knowing where the
47+
/// package in the cache came from can help diagnose a conflict. For example, is it from
48+
/// prebuilt/source-built? Or does the build not have the nupkg anywhere else, and
49+
/// therefore it most likely came from the internet?
50+
/// </summary>
51+
public string[] KnownOriginPackagePaths { get; set; }
52+
4353
[Output]
4454
public ITaskItem[] ConflictingPackageInfos { get; set; }
4555

4656
public override bool Execute()
4757
{
4858
DateTime startTime = DateTime.Now;
4959

60+
var knownNupkgs = new Lazy<ILookup<PackageIdentity, string>>(() =>
61+
{
62+
Log.LogMessage(
63+
MessageImportance.Low,
64+
$"Reading all {nameof(KnownOriginPackagePaths)} package identities to search " +
65+
"for conflicting package origin...");
66+
67+
return KnownOriginPackagePaths.NullAsEmpty().ToLookup(
68+
ReadNuGetPackageInfos.ReadIdentity,
69+
path => path);
70+
});
71+
5072
ConflictingPackageInfos = SourceBuiltPackageInfos
5173
.Where(item =>
5274
{
@@ -72,22 +94,50 @@ public override bool Execute()
7294
MessageImportance.Low,
7395
$"Package id/version found in package cache, verifying: {id} {version}");
7496

75-
bool identical = File.ReadAllBytes(sourceBuiltPath)
76-
.SequenceEqual(File.ReadAllBytes(packageCachePath));
97+
byte[] packageCacheBytes = File.ReadAllBytes(packageCachePath);
7798

78-
if (!identical)
99+
if (packageCacheBytes.SequenceEqual(File.ReadAllBytes(sourceBuiltPath)))
79100
{
80101
Log.LogMessage(
81102
MessageImportance.Low,
82-
"BAD: Source-built nupkg is not byte-for-byte identical " +
83-
$"to nupkg in cache: {id} {version}");
84-
return true;
103+
$"OK: Package in cache is identical to source-built: {id} {version}");
104+
return false;
85105
}
86106

87107
Log.LogMessage(
88108
MessageImportance.Low,
89-
$"OK: Package in cache is identical to source-built: {id} {version}");
90-
return false;
109+
"BAD: Source-built nupkg is not byte-for-byte identical " +
110+
$"to nupkg in cache: {id} {version}");
111+
112+
var ident = new PackageIdentity(id, NuGetVersion.Parse(version));
113+
114+
string message = null;
115+
116+
foreach (string knownNupkg in knownNupkgs.Value[ident])
117+
{
118+
if (packageCacheBytes.SequenceEqual(File.ReadAllBytes(knownNupkg)))
119+
{
120+
Log.LogMessage(
121+
MessageImportance.Low,
122+
$"Found identity match with identical contents: {knownNupkg}");
123+
124+
message = (message ?? "Nupkg found at") + $" '{knownNupkg}'";
125+
}
126+
else
127+
{
128+
Log.LogMessage(
129+
MessageImportance.Low,
130+
$"Package identity match, but contents differ: {knownNupkg}");
131+
}
132+
}
133+
134+
item.SetMetadata(
135+
"WarningMessage",
136+
message ??
137+
"Origin nupkg not found in build directory. It may have been " +
138+
"downloaded by NuGet restore.");
139+
140+
return true;
91141
})
92142
.ToArray();
93143

0 commit comments

Comments
 (0)