diff --git a/src/SourceBuild/Arcade/eng/common/templates/steps/source-build-run-tarball-build.yml b/src/SourceBuild/Arcade/eng/common/templates/steps/source-build-run-tarball-build.yml
index 3f2ebe588..e4cdd156f 100644
--- a/src/SourceBuild/Arcade/eng/common/templates/steps/source-build-run-tarball-build.yml
+++ b/src/SourceBuild/Arcade/eng/common/templates/steps/source-build-run-tarball-build.yml
@@ -19,7 +19,8 @@ steps:
- script: |
set -x
- ./build.sh
+ ./build.sh \
+ --online
workingDirectory: ${{ parameters.sourceFolder }}
displayName: Build Tarball
condition: and(${{ parameters.condition }}, succeeded())
diff --git a/src/SourceBuild/tarball/content/ArcadeOverrides/SourceBuildArcadeBuild.targets b/src/SourceBuild/tarball/content/ArcadeOverrides/SourceBuildArcadeBuild.targets
index 2e2f9821e..7662ad41d 100644
--- a/src/SourceBuild/tarball/content/ArcadeOverrides/SourceBuildArcadeBuild.targets
+++ b/src/SourceBuild/tarball/content/ArcadeOverrides/SourceBuildArcadeBuild.targets
@@ -87,8 +87,8 @@
$(InnerBuildArgs) /p:EnableSourceControlManagerQueries=false
$(InnerBuildArgs) /p:EnableSourceLink=false
$(InnerBuildArgs) /p:DeterministicSourcePaths=false
+ $(InnerBuildArgs) /p:DotNetBuildOffline=true
$(InnerBuildArgs) /p:DotNetPackageVersionPropsPath=$(DotNetPackageVersionPropsPath)
- $(InnerBuildArgs) /p:DotNetBuildOffline=$(DotNetBuildOffline)
diff --git a/src/SourceBuild/tarball/content/Directory.Build.props b/src/SourceBuild/tarball/content/Directory.Build.props
index 9c556df3f..2cd961ae5 100644
--- a/src/SourceBuild/tarball/content/Directory.Build.props
+++ b/src/SourceBuild/tarball/content/Directory.Build.props
@@ -92,7 +92,6 @@
$(ArtifactsDir)
- $(BaseOutputPath)src/
$(ProjectDir).git/modules/src/
$(ProjectDir)Tools/
$(ToolsDir)source-built/
@@ -123,8 +122,7 @@
$(LocalBlobStorageRoot)aspnetcore/Runtime/
$(IntermediatePath)RestoreSources.props
$(IntermediatePath)PackageVersions.props
- $(IntermediatePath)GennedPackageVersions.props
- $(IntermediatePath)PackageVersions.props
+ $(IntermediatePath)GennedPackageVersions.props
$(BaseOutputPath)logs/
$(BaseOutputPath)msbuild-debug/
$(BaseOutputPath)roslyn-debug/
@@ -149,8 +147,7 @@
$(PackageReportDir)prodcon-build.xml
$(PackageReportDir)poisoned.txt
$(BaseOutputPath)conflict-report/
- $(PackageReportDir)PrebuiltBurndownData-offline.csv
- $(PackageReportDir)PrebuiltBurndownData-online.csv
+ $(PackageReportDir)PrebuiltBurndownData.csv
$(IntermediatePath)reference-packages/
$(IntermediatePath)text-only-packages/
$(IntermediatePath)external-tarballs/
@@ -159,19 +156,15 @@
See corresponding change in build-source-tarball.sh to copy reference-packages & external-tarballs
from source-build bin dir to tarball packages/reference dir & packages/archive.
-->
- $(ProjectDir)packages/archive/
- $(ProjectDir)packages/reference/
- $(ProjectDir)packages/text-only/
+ $(ProjectDir)packages/archive/
+ $(ProjectDir)packages/reference/
+ $(ProjectDir)packages/text-only/
$(ReferencePackagesBaseDir)packages/
Private.SourceBuilt.Artifacts
https://dotnetcli.azureedge.net/source-built-artifacts/assets/
archiveArtifacts.txt
$(ExternalTarballsDir)$(ArchiveArtifactsTextFileName)
- $(ToolsLocalDir)prebuilt-baseline-
- $(BaselineDataFile)offline.xml
- $(BaselineDataFile)online.xml
- $(OfflineBaselineDataFile)
- $(OnlineBaselineDataFile)
+ $(ToolsLocalDir)prebuilt-baseline.xml
$(ProjectDir)test/exclusions/
diff --git a/src/SourceBuild/tarball/content/Directory.Build.targets b/src/SourceBuild/tarball/content/Directory.Build.targets
index c9cd51f95..15a75864c 100644
--- a/src/SourceBuild/tarball/content/Directory.Build.targets
+++ b/src/SourceBuild/tarball/content/Directory.Build.targets
@@ -10,47 +10,6 @@
-
-
-
-
-
-
-
-
- $(IgnoredRepos);https://dev.azure.com/dnceng/internal/_git/dotnet-optimization
- $(IgnoredRepos);https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted
- $(IgnoredRepos);https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted
- $(IgnoredRepos);https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization
- $(IgnoredRepos);https://dev.azure.com/dnceng/internal/_git/dotnet-core-setup
- $(IgnoredRepos);https://github.com/dotnet/source-build-reference-packages
-
- $(ClonedSubmoduleDirectory)
-
- $(DarcCloneArguments) --git-dir-folder $(ClonedSubmoduleGitRootDirectory)
- $(DarcCloneArguments) --include-toolset
- $(DarcCloneArguments) --ignore-repos "$(IgnoredRepos)"
- $(DarcCloneArguments) --debug
-
-
- bogus
- $(DarcCloneArguments) --azdev-pat $(AzDoPat)
- $(DarcCloneArguments) --github-pat bogus
-
-
- $(DarcCloneArguments) --depth 0
-
- $(DotNetCliToolDir)dotnet $(DarcDll) clone $(DarcCloneArguments)
-
-
-
diff --git a/src/SourceBuild/tarball/content/build.proj b/src/SourceBuild/tarball/content/build.proj
index c8f1995ce..1b07656b3 100644
--- a/src/SourceBuild/tarball/content/build.proj
+++ b/src/SourceBuild/tarball/content/build.proj
@@ -47,59 +47,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
- N/A
-
-
-
-
-
-
-
-
-
- N/A
-
-
-
-
-
-
-
@@ -137,11 +84,8 @@
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(CompletedSemaphorePath)GeneratePrebuiltBurndownData.complete" >
-
+ PrebuiltBaselineFile="$(BaselineDataFile)"
+ OutputFilePath="$(PrebuiltBurndownDataFile)" />
diff --git a/src/SourceBuild/tarball/content/build.sh b/src/SourceBuild/tarball/content/build.sh
index 13f8ccc7b..21c366fe1 100755
--- a/src/SourceBuild/tarball/content/build.sh
+++ b/src/SourceBuild/tarball/content/build.sh
@@ -5,7 +5,7 @@ IFS=$'\n\t'
usage() {
echo "usage: $0 [options]"
echo "options:"
- echo " --with-ref-packages
use the specified directory of reference packages"
+ echo " --online build using online sources"
echo " --with-packages use the specified directory of previously-built packages"
echo " --with-sdk use the SDK in the specified directory for bootstrapping"
echo "use -- to send the remaining arguments to MSBuild"
@@ -14,7 +14,7 @@ usage() {
SCRIPT_ROOT="$(cd -P "$( dirname "$0" )" && pwd)"
-MSBUILD_ARGUMENTS=("/p:OfflineBuild=true" "/flp:v=detailed")
+MSBUILD_ARGUMENTS=("/flp:v=detailed")
CUSTOM_REF_PACKAGES_DIR=''
CUSTOM_PREVIOUSLY_BUILT_PACKAGES_DIR=''
alternateTarget=false
@@ -31,6 +31,9 @@ while :; do
alternateTarget=true
MSBUILD_ARGUMENTS+=( "/t:RunSmokeTest" )
;;
+ --online)
+ MSBUILD_ARGUMENTS+=( "/p:BuildWithOnlineSources=true")
+ ;;
--with-packages)
CUSTOM_PREVIOUSLY_BUILT_PACKAGES_DIR="$(cd -P "$2" && pwd)"
if [ ! -d "$CUSTOM_PREVIOUSLY_BUILT_PACKAGES_DIR" ]; then
diff --git a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.AllowedPrebuilts.targets b/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.AllowedPrebuilts.targets
deleted file mode 100644
index f4191b490..000000000
--- a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.AllowedPrebuilts.targets
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.DestructiveCleanup.targets b/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.DestructiveCleanup.targets
deleted file mode 100644
index 18ef94a13..000000000
--- a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.DestructiveCleanup.targets
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.KnownExtraPrebuilts.targets b/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.KnownExtraPrebuilts.targets
deleted file mode 100644
index fc10206fc..000000000
--- a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.KnownExtraPrebuilts.targets
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.TextOnlyPrebuilts.targets b/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.TextOnlyPrebuilts.targets
deleted file mode 100644
index efc0276b4..000000000
--- a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.TextOnlyPrebuilts.targets
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-
-
-
-
-
- $([MSBuild]::NormalizeDirectory('$(TarballRootDir)', 'packages', 'text-only'))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $([System.IO.Path]::GetDirectoryName('$(TextOnlyPackageRootDir)'))
- $([System.IO.Path]::GetDirectoryName('$(PackageVersionDirFile)'))
- $([System.IO.Path]::GetFileName('$(PackageVersionDirFile)'))
- $([System.IO.Path]::GetFileName('$(PackageIdDirFile)'))
-
- $([MSBuild]::NormalizeDirectory('$(TextOnlyPackageBaseDir)', '$(PackageId)', '$(PackageVersion)'))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.targets b/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.targets
deleted file mode 100644
index 3948a9cc6..000000000
--- a/src/SourceBuild/tarball/content/eng/SourceBuild.Tarball.targets
+++ /dev/null
@@ -1,386 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- $([MSBuild]::NormalizeDirectory('$(TarballRoot)'))
- $([MSBuild]::NormalizeDirectory('$(TarballRootDir)', 'src'))
- $([MSBuild]::NormalizeDirectory('$(TarballRootDir)', 'packages', 'prebuilt'))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(TarballRootDir)source-build-info.txt
-
-
-
-
-
-
-
- $(ProjectDir)tools-local\tasks\Microsoft.DotNet.SourceBuild.Tasks.LeakDetection\Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Detected forbidden prebuilts. They must be removed, or explicitly allowed (see target for details):
- $(PrebuiltErrorText)%0A@(ForbiddenPrebuiltPackageFile -> '%(Identity)', '%0A')
-
-
-
-
-
-
diff --git a/src/SourceBuild/tarball/content/repos/Directory.Build.props b/src/SourceBuild/tarball/content/repos/Directory.Build.props
index 6e0a3e654..ccbb7e16b 100644
--- a/src/SourceBuild/tarball/content/repos/Directory.Build.props
+++ b/src/SourceBuild/tarball/content/repos/Directory.Build.props
@@ -11,8 +11,7 @@
$(RepositoryName)
- $(ClonedSubmoduleDirectory)$(SourceDirectory).$(GitCommitHash)/
- $(SubmoduleDirectory)$(SourceDirectory).$(GitCommitHash)/
+ $(SubmoduleDirectory)$(SourceDirectory).$(GitCommitHash)/
true
$(LoggingDir)$(RepositoryName).log
>> $(RepoConsoleLogFile) 2>&1
@@ -41,19 +40,17 @@
- '$(RepositoryName)'
- $(ProjectBuildReason) to produce tarball
- $(ProjectBuildReason) in tarball
+ '$(RepositoryName) in tarball'
-
+
-
+
@@ -134,8 +131,7 @@
- $(PackagesDir)
- $(ArcadeBootstrapPackageDir)
+ $(ArcadeBootstrapPackageDir)
$(ARCADE_BOOTSTRAP_VERSION)
diff --git a/src/SourceBuild/tarball/content/repos/Directory.Build.targets b/src/SourceBuild/tarball/content/repos/Directory.Build.targets
index 813cc6684..8d13b92de 100644
--- a/src/SourceBuild/tarball/content/repos/Directory.Build.targets
+++ b/src/SourceBuild/tarball/content/repos/Directory.Build.targets
@@ -1,6 +1,6 @@
-
+
@@ -54,7 +54,7 @@
$(RepoApiArgs) /p:DotNetRestoreSourcePropsPath=$(RestoreSourcePropsPath)
- $(RepoApiArgs) /p:DotNetBuildOffline=true
+ $(RepoApiArgs) /p:DotNetBuildOffline=true
@@ -165,28 +165,25 @@
-
-
+ BuildWithOnlineSources="$(BuildWithOnlineSources)"
+ KeepFeedPrefixes="@(KeepFeedPrefixes)" />
+ />
+ />
+ />
<_DotNetRestoreSources Include="$(ExtraRestoreSourcePath)" Condition="'$(ExtraRestoreSourcePath)' != ''"/>
<_DotNetRestoreSources Include="$(SourceBuiltPackagesPath)" />
- <_DotNetRestoreSources Include="$(ReferencePackagesDir)" Condition="'$(OfflineBuild)' == 'true'"/>
- <_DotNetRestoreSources Include="$(PrebuiltPackagesPath)" Condition="'$(OfflineBuild)' == 'true'"/>
- <_DotNetRestoreSources Include="$(PrebuiltSourceBuiltPackagesPath)" Condition="'$(OfflineBuild)' == 'true'"/>
+ <_DotNetRestoreSources Include="$(ReferencePackagesDir)"/>
+ <_DotNetRestoreSources Include="$(PrebuiltPackagesPath)"/>
+ <_DotNetRestoreSources Include="$(PrebuiltSourceBuiltPackagesPath)"/>
<_AdditionalAssetDirs Include="$(SourceBuiltToolsetDir)" Condition="Exists('$(SourceBuiltToolsetDir)')" />
@@ -696,7 +693,7 @@
-
+
@@ -710,8 +707,7 @@
-
-
+
diff --git a/src/SourceBuild/tarball/content/repos/aspnetcore.proj b/src/SourceBuild/tarball/content/repos/aspnetcore.proj
index 50e459d14..e8b821652 100644
--- a/src/SourceBuild/tarball/content/repos/aspnetcore.proj
+++ b/src/SourceBuild/tarball/content/repos/aspnetcore.proj
@@ -39,8 +39,8 @@
$(ProjectDirectory)NuGet.config
$(SourceBuiltPackagesPath)
- $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
- $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
+ $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
+ $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
diff --git a/src/SourceBuild/tarball/content/repos/installer.proj b/src/SourceBuild/tarball/content/repos/installer.proj
index d2a06b2a9..97837cc77 100644
--- a/src/SourceBuild/tarball/content/repos/installer.proj
+++ b/src/SourceBuild/tarball/content/repos/installer.proj
@@ -57,7 +57,7 @@
true
$(SourceBuiltPackagesPath)
- $(EnvironmentExternalRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
+ $(EnvironmentExternalRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
true
diff --git a/src/SourceBuild/tarball/content/repos/msbuild.proj b/src/SourceBuild/tarball/content/repos/msbuild.proj
index b0d6f22da..1a442380d 100644
--- a/src/SourceBuild/tarball/content/repos/msbuild.proj
+++ b/src/SourceBuild/tarball/content/repos/msbuild.proj
@@ -35,8 +35,8 @@
$(ProjectDirectory)global.json
$(SourceBuiltPackagesPath)
- $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
- $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
+ $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
+ $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
@@ -68,14 +68,13 @@
but the NuGet resolver seems flaky so we're using our resolver instead. We only have access to
the nupkg ahead of time when building a tarball, so only enable this workaround then.
-->
-
+
diff --git a/src/SourceBuild/tarball/content/repos/package-source-build.proj b/src/SourceBuild/tarball/content/repos/package-source-build.proj
index c78fd79e5..e3492667b 100644
--- a/src/SourceBuild/tarball/content/repos/package-source-build.proj
+++ b/src/SourceBuild/tarball/content/repos/package-source-build.proj
@@ -5,8 +5,7 @@
false
$(SubmoduleDirectory)$(RepositoryName)/
true
- $(PackageVersionPropsPath)
- $(GennedPackageVersionPropsPath)
+ $(GennedPackageVersionPropsPath)
diff --git a/src/SourceBuild/tarball/content/repos/runtime.common.props b/src/SourceBuild/tarball/content/repos/runtime.common.props
index 994e7bf22..55fe99d15 100644
--- a/src/SourceBuild/tarball/content/repos/runtime.common.props
+++ b/src/SourceBuild/tarball/content/repos/runtime.common.props
@@ -63,8 +63,8 @@
$(LibrariesBuildArguments) /p:BuildAllOOBPackages=true
$(LibrariesBuildArguments) /p:KeepNativeSymbols=true
$(LibrariesBuildArguments) /p:BuiltSdkPackageOverride=""
- $(LibrariesBuildArguments) /p:MicrosoftNETCoreDotNetHostPackageVersion=$(DOTNET_HOST_BOOTSTRAP_VERSION)
- $(LibrariesBuildArguments) /p:MicrosoftNETCoreDotNetHostPolicyPackageVersion=$(DOTNET_HOST_BOOTSTRAP_VERSION)
+ $(LibrariesBuildArguments) /p:MicrosoftNETCoreDotNetHostPackageVersion=$(DOTNET_HOST_BOOTSTRAP_VERSION)
+ $(LibrariesBuildArguments) /p:MicrosoftNETCoreDotNetHostPolicyPackageVersion=$(DOTNET_HOST_BOOTSTRAP_VERSION)
@@ -120,8 +120,8 @@
$(SourceBuiltPackagesPath)
$(EnvironmentRestoreSources)%3B$(ShippingPackagesOutput)
$(EnvironmentRestoreSources)%3B$(NonShippingPackagesOutput)
- $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
- $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
+ $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
+ $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
diff --git a/src/SourceBuild/tarball/content/repos/sdk.proj b/src/SourceBuild/tarball/content/repos/sdk.proj
index 2f8a83910..cad87db5a 100644
--- a/src/SourceBuild/tarball/content/repos/sdk.proj
+++ b/src/SourceBuild/tarball/content/repos/sdk.proj
@@ -36,8 +36,8 @@
false
$(SourceBuiltPackagesPath)
- $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
- $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
+ $(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
+ $(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json
diff --git a/src/SourceBuild/tarball/content/tools-local/acquire-darc/acquire-darc.proj b/src/SourceBuild/tarball/content/tools-local/acquire-darc/acquire-darc.proj
deleted file mode 100644
index 054a65119..000000000
--- a/src/SourceBuild/tarball/content/tools-local/acquire-darc/acquire-darc.proj
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/SourceBuild/tarball/content/tools-local/init-build.proj b/src/SourceBuild/tarball/content/tools-local/init-build.proj
index dfda2bfa9..94f73787f 100644
--- a/src/SourceBuild/tarball/content/tools-local/init-build.proj
+++ b/src/SourceBuild/tarball/content/tools-local/init-build.proj
@@ -5,7 +5,6 @@
-
@@ -15,10 +14,7 @@
-
-
+
$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)
@@ -42,7 +38,6 @@
@@ -115,7 +110,6 @@
@@ -136,7 +130,6 @@
diff --git a/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline-offline.xml b/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline-offline.xml
deleted file mode 100644
index cca3774b3..000000000
--- a/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline-offline.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
- centos.7-x64
-
- src/ApplicationInsights-dotnet.53b80940842204f78708a538628288ff5d741a1d/
- src/arcade.6eec4404c2df5bfa46e5da52383c881c5cca3a9f/
- src/xdt.c01a538851a8ab1a1fbeb2e6243f391fff7587b4/
- src/dotnet-aspnetcore.2670c128d522473e146ff9f8159bfffdfe694cd9/
- src/cliCommandLineParser.0e89c2116ad28e404ba56c14d1c3f938caa25a01/
- src/command-line-api.afd010ba8cb3cbd714c734465d1a5de1ee133e2d/
- src/common.6e37cdfe96ac8b06a923242120169fafacd720e6/
- src/cssparser.d6d86bcd8c162b1ae22ef00955ff748d028dd0ee/
- src/diagnostics.47296ca69bb66180c132f3b16667f904dfc7c6c7/
- src/fsharp.da6be68280c89131cdba2045525b80890401defd/
- src/Humanizer.b30550eed103a6970d8465fe7c5c16300b70be81/
- src/dotnet-installer.71365b4d424b0860ceb9ad8ee47f7cd08c55c362/
- src/known-good-tests./
- src/known-good./
- src/linker.25604250cf2663aed6630e305cc0538aeebda80a/
- src/msbuild.39993bd9d02917993b6147a9973dc3aa6e9b00c7/
- src/netcorecli-fsc/
- src/Newtonsoft.Json.cac0690ad133c5e166ce5642dc71175791404fad/
- src/Newtonsoft.Json.e43dae94c26f0c30e9095327a3a9eac87193923d/
- src/NuGet.Client.830c8be45dbbccd411ecf6080abff0c2c98079cf/
- src/package-source-build/
- src/roslyn-analyzers.77b259353aa44ec1510951a75c6e7ed6e662a001/
- src/roslyn.9ed4b774d20940880de8df1ca8b07508aa01c8cd/
- src/dotnet-runtime.cb5f173b9696d9d00a544b953d95190ab3b56df2/
- src/dotnet-runtime.cb5f173b9696d9d00a544b953d95190ab3b56df2/
- src/dotnet-sdk.ef14c79a16171496e2d972edd9a7874d596f624d/
- src/sourcelink.f175b06862f889474b689a57527e489101c774cc/
- src/symreader.f8a3ba85aed339fb8d08ca26f3876b28c32d58ee/
- src/templating.568c09b99075179607c572f7b9f3ad3d706f1fc3/
- src/test-templates.956e14dedd3a3ac981b320d66c6d389387a2954a/
- src/vstest.212656d7b384a506aa714999f678b3ace82d114e/
- src/xliff-tasks.a52f3d7fb58470749ee4035fbbcb7e63c78b0459/
- Tools/
- tools-local/tasks/
- artifacts/obj/
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline-online.xml b/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline-online.xml
deleted file mode 100755
index 03370c501..000000000
--- a/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline-online.xml
+++ /dev/null
@@ -1,457 +0,0 @@
-
- centos.7-x64
-
- artifacts/src/ApplicationInsights-dotnet.53b80940842204f78708a538628288ff5d741a1d/
- artifacts/src/arcade.6eec4404c2df5bfa46e5da52383c881c5cca3a9f/
- artifacts/src/xdt.c01a538851a8ab1a1fbeb2e6243f391fff7587b4/
- artifacts/src/dotnet-aspnetcore.b7a2ec8c7ed6b48857af0a69688a73e8c14fe6cb/
- artifacts/src/CliCommandLineParser.0e89c2116ad28e404ba56c14d1c3f938caa25a01/
- artifacts/src/command-line-api.6ddde11ed45e3f4b9d80c97670f347dbfda15c3f/
- artifacts/src/common.6e37cdfe96ac8b06a923242120169fafacd720e6/
- artifacts/src/cssparser.d6d86bcd8c162b1ae22ef00955ff748d028dd0ee/
- artifacts/src/diagnostics.47296ca69bb66180c132f3b16667f904dfc7c6c7/
- artifacts/src/fsharp.7ce7132f1459095e635194d09d6f73265352029a/
- artifacts/src/Humanizer.b30550eed103a6970d8465fe7c5c16300b70be81/
- artifacts/src/dotnet-installer.db7cc87d512335808e3806067f2bf9b31379e1db/
- artifacts/src/known-good-tests./
- artifacts/src/known-good./
- artifacts/src/linker.c43f981eec336c1dc4fd0ead84b5e09db9377d9e/
- artifacts/src/msbuild.5e4b48a27efce55a613664b58d353ab4c8d1f6c1/
- src/netcorecli-fsc/
- artifacts/src/Newtonsoft.Json.cac0690ad133c5e166ce5642dc71175791404fad/
- artifacts/src/Newtonsoft.Json.e43dae94c26f0c30e9095327a3a9eac87193923d/
- artifacts/src/nuget.client.d525b0e670f3b6cbd5c73a35f04730a9f658c852/
- src/package-source-build/
- artifacts/src/roslyn-analyzers.ce71b27be743710012c0460071da188b2f05959c/
- artifacts/src/roslyn.59eedc33d35754759994155ea2f4e1012a9951e3/
- artifacts/src/dotnet-runtime.2f740adc1457e8a28c1c072993b66f515977eb51/
- artifacts/src/dotnet-runtime.2f740adc1457e8a28c1c072993b66f515977eb51/
- artifacts/src/dotnet-sdk.51369266643769f9f0c1184e89715cd1045126d0/
- artifacts/src/sourcelink.f175b06862f889474b689a57527e489101c774cc/
- artifacts/src/symreader.f8a3ba85aed339fb8d08ca26f3876b28c32d58ee/
- artifacts/src/templating.8470ff317250d761c72f920b8ea1c0700b230eb3/
- artifacts/src/test-templates.956e14dedd3a3ac981b320d66c6d389387a2954a/
- artifacts/src/vstest.99b911a57a02fc5d2eeef23e9ab8cbea4505678b/
- artifacts/src/xliff-tasks.a52f3d7fb58470749ee4035fbbcb7e63c78b0459/
- Tools/
- tools-local/tasks/
- artifacts/obj/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline.xml b/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline.xml
new file mode 100755
index 000000000..444b11553
--- /dev/null
+++ b/src/SourceBuild/tarball/content/tools-local/prebuilt-baseline.xml
@@ -0,0 +1,168 @@
+
+ fedora.33-x64
+
+ src/arcade.a3377cccde8639089f99107e2ba5df2c8cbe6394/
+ src/aspnetcore./
+ src/clicommandlineparser.3198bf5660cad3dab85f5475bf1fda9688146e3f/
+ src/command-line-api.5e855e911de7c56fe28400c4500e888fe2a3da8e/
+ src/diagnostics.6f48c2ae749c29b687af0353e6c2a9590d7e3d22/
+ src/fsharp./
+ src/installer.c6ec4363003b18d8e587620baa36205b80ee3074/
+ src/known-good-tests./
+ src/known-good./
+ src/linker.f2588193553431636b9853b0f87209fa395a72c5/
+ src/msbuild./
+ src/nuget.client./
+ src/package-source-build/
+ src/roslyn-analyzers./
+ src/roslyn./
+ src/runtime./
+ src/runtime./
+ src/sdk./
+ src/source-build-reference-packages.36fb56afdf0ee2fb2e0833bdef98dfde12a0837b/
+ src/source-build.3fb25b8db3bec654e37e71a5b2b7fde14444bc2f/
+ src/sourcelink.4b584dbc392bb1aad49c2eb1ab84d8b489b6dccc/
+ src/symreader.1968a003d845d119a9d38ac4daaeea22897f7daf/
+ src/templating.3bc0d90f3e450f3e4ebda128081d091fb42968e3/
+ src/test-templates.6898c1c70c2d14e9725ddab6e1ebe8084c4d7e27/
+ src/vstest./
+ src/xdt.6a46e7c886cdf499ba3433f665ab417be814135e/
+ src/xliff-tasks.71c811561ad4dcf46825a5077fbcc668ab74754f/
+ Tools/
+ tools-local/tasks/
+ artifacts/obj/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj
index ab8eb402b..571e83c13 100644
--- a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj
+++ b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj
@@ -13,13 +13,7 @@
15.7.179
-
- Configuration=netstandard_Debug
- Configuration=netstandard_Release
- {D68133BD-1E63-496E-9EDE-4FBDBF77B486}
- Mono.Cecil
-
-
+
Configuration=netstandard_Debug
Configuration=netstandard_Release
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}
diff --git a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/RemoveInternetSourcesFromNuGetConfig.cs b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/RemoveInternetSourcesFromNuGetConfig.cs
index 65aa69ac8..68a01adc4 100755
--- a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/RemoveInternetSourcesFromNuGetConfig.cs
+++ b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/RemoveInternetSourcesFromNuGetConfig.cs
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Xml;
using System.Xml.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
@@ -25,7 +26,7 @@ namespace Microsoft.DotNet.Build.Tasks
///
/// Whether to work in offline mode (remove all internet sources) or online mode (remove only authenticated sources)
///
- public bool OfflineBuild { get; set; }
+ public bool BuildWithOnlineSources { get; set; }
///
/// A list of prefix strings that make the task keep a package source unconditionally. For
@@ -36,7 +37,9 @@ namespace Microsoft.DotNet.Build.Tasks
public override bool Execute()
{
- XDocument d = XDocument.Load(NuGetConfigFile);
+ string xml = File.ReadAllText(NuGetConfigFile);
+ string newLineChars = FileUtilities.DetectNewLineChars(xml);
+ XDocument d = XDocument.Parse(xml);
XElement packageSourcesElement = d.Root.Descendants().First(e => e.Name == "packageSources");
XElement disabledPackageSourcesElement = d.Root.Descendants().FirstOrDefault(e => e.Name == "disabledPackageSources");
@@ -53,15 +56,15 @@ namespace Microsoft.DotNet.Build.Tasks
}
string feedUrl = e.Attribute("value").Value;
- if (OfflineBuild)
- {
- return !(feedUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || feedUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase));
- }
- else
+ if (BuildWithOnlineSources)
{
return !( feedUrl.StartsWith("https://pkgs.dev.azure.com/dnceng/_packaging", StringComparison.OrdinalIgnoreCase) ||
feedUrl.StartsWith("https://pkgs.dev.azure.com/dnceng/internal/_packaging", StringComparison.OrdinalIgnoreCase) );
}
+ else
+ {
+ return !(feedUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || feedUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase));
+ }
}
return true;
@@ -72,9 +75,9 @@ namespace Microsoft.DotNet.Build.Tasks
// Remove disabledPackageSources element so if any internal packages remain, they are used in source-build
disabledPackageSourcesElement?.ReplaceNodes(new XElement("clear"));
- using (FileStream fs = new FileStream(NuGetConfigFile, FileMode.Create, FileAccess.ReadWrite))
+ using (var w = XmlWriter.Create(NuGetConfigFile, new XmlWriterSettings { NewLineChars = newLineChars, Indent = true }))
{
- d.Save(fs);
+ d.Save(w);
}
return true;
diff --git a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/WriteSourceRepoProperties.cs b/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/WriteSourceRepoProperties.cs
deleted file mode 100644
index 5b96f9f87..000000000
--- a/src/SourceBuild/tarball/content/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/WriteSourceRepoProperties.cs
+++ /dev/null
@@ -1,317 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.Build.Framework;
-using Microsoft.Build.Tasks;
-using Microsoft.Build.Utilities;
-using Microsoft.DotNet.SourceBuild.Tasks.Models;
-using NuGet.Versioning;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Xml.Serialization;
-
-namespace Microsoft.DotNet.Build.Tasks
-{
- public class WriteSourceRepoProperties : Task
- {
- [Required]
- public string VersionDetailsFile { get; set; }
-
- [Required]
- public string ClonedSubmoduleGitRootDirectory { get; set; }
-
- [Required]
- public string ClonedSubmoduleDirectory { get; set; }
-
- [Required]
- public string SourceBuildMetadataDir { get; set; }
-
- public override bool Execute()
- {
- var serializer = new XmlSerializer(typeof(VersionDetails));
-
- VersionDetails versionDetails = null;
- using (var stream = File.OpenRead(VersionDetailsFile))
- {
- versionDetails = (VersionDetails)serializer.Deserialize(stream);
- }
-
- var allRepoProps = new Dictionary();
-
- foreach (var dep in versionDetails.ToolsetDependencies.Concat(versionDetails.ProductDependencies))
- {
- Log.LogMessage(MessageImportance.Normal, $"[{DateTimeOffset.Now}] Starting dependency {dep.ToString()}");
- string repoPath = DeriveRepoPath(ClonedSubmoduleDirectory, dep.Uri, dep.Sha);
- string repoGitDir = DeriveRepoGitDirPath(ClonedSubmoduleGitRootDirectory, dep.Uri);
- if (Directory.Exists(repoGitDir))
- {
- foreach (string repoName in GetRepoNamesOrDefault(dep))
- {
- string safeRepoName = repoName.Replace("-", "");
- try
- {
- WriteMinimalMetadata(repoPath, dep.Uri, dep.Sha);
- WriteSourceBuildMetadata(SourceBuildMetadataDir, repoGitDir, dep);
- if (File.Exists(Path.Combine(repoPath, ".gitmodules")))
- {
- HandleSubmodules(repoPath, repoGitDir, dep);
- }
- allRepoProps[$"{safeRepoName}GitCommitHash"] = dep.Sha;
- allRepoProps[$"{safeRepoName}OutputPackageVersion"] = dep.Version;
- }
- catch (Exception e)
- {
- Log.LogErrorFromException(e, true, true, null);
- }
- }
- }
- else
- {
- Log.LogMessage(MessageImportance.Normal, $"[{DateTimeOffset.Now}] Skipping dependency {dep.ToString()} - git dir {repoGitDir} doesn't exist");
- }
- }
- string allRepoPropsPath = Path.Combine(SourceBuildMetadataDir, "AllRepoVersions.props");
- Log.LogMessage(MessageImportance.Normal, $"[{DateTimeOffset.Now}] Writing all repo versions to {allRepoPropsPath}");
- WritePropsFile(allRepoPropsPath, allRepoProps);
-
- return !Log.HasLoggedErrors;
- }
-
- private void WriteSourceBuildMetadata(string sourceBuildMetadataPath, string repoGitDir, Dependency dependency)
- {
- foreach (string repoName in GetRepoNamesOrDefault(dependency))
- {
- string propsPath = Path.Combine(sourceBuildMetadataPath, $"{repoName}.props");
- string commitCount = GetCommitCount(repoGitDir, dependency.Sha);
- DerivedVersion derivedVersion = GetVersionInfo(dependency.Version, commitCount);
- var repoProps = new Dictionary
- {
- ["GitCommitHash"] = dependency.Sha,
- ["GitCommitCount"] = commitCount,
- ["GitCommitDate"] = GetCommitDate(repoGitDir, dependency.Sha),
- ["OfficialBuildId"] = derivedVersion.OfficialBuildId,
- ["OutputPackageVersion"] = dependency.Version,
- ["PreReleaseVersionLabel"] = derivedVersion.PreReleaseVersionLabel,
- ["IsStable"] = string.IsNullOrWhiteSpace(derivedVersion.PreReleaseVersionLabel) ? "true" : "false",
- };
- WritePropsFile(propsPath, repoProps);
- }
- }
-
-
- ///
- /// Reverse a version in the Arcade style (https://github.com/dotnet/arcade/blob/fb92b14d8cd07cf44f8f7eefa8ac58d7ffd05f3f/src/Microsoft.DotNet.Arcade.Sdk/tools/Version.BeforeCommonTargets.targets#L18)
- /// back to an OfficialBuildId + ReleaseLabel which we can then supply to get the same resulting version number.
- ///
- /// The complete version, e.g. 1.0.0-beta1-19720.5
- /// The current commit count of the repo. This is used for some repos that do not use the standard versioning scheme.
- ///
- private static DerivedVersion GetVersionInfo(string version, string commitCount)
- {
- var nugetVersion = new NuGetVersion(version);
-
- if (!string.IsNullOrWhiteSpace(nugetVersion.Release))
- {
- var releaseParts = nugetVersion.Release.Split('-', '.');
- if (releaseParts.Length == 2)
- {
- if (releaseParts[1].TrimStart('0') == commitCount)
- {
- // core-sdk does this - OfficialBuildId is only used for their fake package and not in anything shipped
- return new DerivedVersion { OfficialBuildId = DateTime.Now.ToString("yyyyMMdd.1"), PreReleaseVersionLabel = releaseParts[0] };
- }
- else
- {
- // NuGet does this - arbitrary build IDs
- return new DerivedVersion { OfficialBuildId = releaseParts[1], PreReleaseVersionLabel = releaseParts[0] };
- }
- }
- else if (releaseParts.Length == 3)
- {
- // VSTest uses full dates for the first part of their preview build numbers
- if (DateTime.TryParseExact(releaseParts[1], "yyyyMMdd", new CultureInfo("en-US"), DateTimeStyles.AssumeLocal, out DateTime fullDate))
- {
- return new DerivedVersion { OfficialBuildId = $"{releaseParts[1]}.{releaseParts[2]}", PreReleaseVersionLabel = releaseParts[0] };
- }
- else if (int.TryParse(releaseParts[1], out int datePart) && int.TryParse(releaseParts[2], out int buildPart))
- {
- if (datePart > 1 && datePart < 8 && buildPart > 1000 && buildPart < 10000)
- {
- return new DerivedVersion { OfficialBuildId = releaseParts[2], PreReleaseVersionLabel = $"{releaseParts[0]}.{releaseParts[1]}" };
- }
- else
- {
- return new DerivedVersion { OfficialBuildId = $"20{((datePart / 1000))}{((datePart % 1000) / 50):D2}{(datePart % 50):D2}.{buildPart}", PreReleaseVersionLabel = releaseParts[0] };
- }
- }
- }
- else if (releaseParts.Length == 4)
- {
- // new preview version style, e.g. 5.0.0-preview.7.20365.12
- if (int.TryParse(releaseParts[2], out int datePart) && int.TryParse(releaseParts[3], out int buildPart))
- {
- return new DerivedVersion { OfficialBuildId = $"20{((datePart / 1000))}{((datePart % 1000) / 50):D2}{(datePart % 50):D2}.{buildPart}", PreReleaseVersionLabel = $"{releaseParts[0]}.{releaseParts[1]}" };
- }
- }
- }
- else
- {
- // finalized version number (x.y.z) - probably not our code
- // VSTest, Application Insights, Newtonsoft.Json do this
- return new DerivedVersion { OfficialBuildId = DateTime.Now.ToString("yyyyMMdd.1"), PreReleaseVersionLabel = string.Empty };
- }
-
- throw new FormatException($"Can't derive a build ID from version {version} (commit count {commitCount}, release {string.Join(";", nugetVersion.Release.Split('-', '.'))})");
- }
-
- private static string GetDefaultRepoNameFromUrl(string repoUrl)
- {
- if (repoUrl.EndsWith(".git"))
- {
- repoUrl = repoUrl.Substring(0, repoUrl.Length - ".git".Length);
- }
- return repoUrl.Substring(repoUrl.LastIndexOf("/") + 1);
- }
-
- private static IEnumerable GetRepoNamesOrDefault(Dependency dependency)
- {
- return dependency.RepoNames ?? new[] { GetDefaultRepoNameFromUrl(dependency.Uri) };
- }
-
- private static string DeriveRepoGitDirPath(string gitDirPath, string repoUrl)
- {
- return Path.Combine(gitDirPath, $"{GetDefaultRepoNameFromUrl(repoUrl)}.git");
- }
-
- private static string DeriveRepoPath(string sourceDirPath, string repoUrl, string hash)
- {
- // hash could actually be a branch or tag, make it filename-safe
- hash = hash.Replace('/', '-').Replace('\\', '-').Replace('?', '-').Replace('*', '-').Replace(':', '-').Replace('|', '-').Replace('"', '-').Replace('<', '-').Replace('>', '-');
- return Path.Combine(sourceDirPath, $"{GetDefaultRepoNameFromUrl(repoUrl)}.{hash}");
- }
-
- private string GetCommitCount(string gitDir, string hash)
- {
- return RunGitCommand($"rev-list --count {hash}", gitDir: gitDir);
- }
-
- private string GetCommitDate(string gitDir, string hash)
- {
- return RunGitCommand($"log -1 --format=%cd --date=short {hash}", gitDir: gitDir);
- }
-
- private IEnumerable GetSubmoduleInfo(string gitModulesFilePath)
- {
- string submoduleProps = RunGitCommand($"config --file={gitModulesFilePath} --list");
- var submodulePathRegex = new Regex(@"submodule\.(?.*)\.path=(?.*)");
- foreach (Match m in submodulePathRegex.Matches(submoduleProps))
- {
- yield return new SubmoduleInfo { Name = m.Groups["submoduleName"].Value, Path = m.Groups["submodulePath"].Value };
- }
- }
-
- private string RunGitCommand(string command, string workTree = null, string gitDir = null)
- {
- // Windows Git requires these to be before the command
- if (workTree != null)
- {
- command = $"--work-tree={workTree} {command}";
- }
- if (gitDir != null)
- {
- command = $"--git-dir={gitDir} {command}";
- }
-
- var exec = new Exec
- {
- BuildEngine = BuildEngine,
- Command = $"git {command}",
- LogStandardErrorAsError = true,
- ConsoleToMSBuild = true,
- };
-
- if (!exec.Execute() || exec.ExitCode != 0)
- {
- string error = string.Join(Environment.NewLine, exec.ConsoleOutput.Select(o => o.ItemSpec));
- throw new InvalidOperationException($"git command '{command}' failed with exit code {exec.ExitCode} and error {error ?? ""}");
- }
- string output = string.Join(Environment.NewLine, exec.ConsoleOutput.Select(o => o.ItemSpec));
- return output.Trim();
- }
-
- private void HandleSubmodules(string sourceDirPath, string gitDirPath, Dependency dependency)
- {
- var gitModulesPath = Path.Combine(sourceDirPath, ".gitmodules");
- foreach (SubmoduleInfo submodule in GetSubmoduleInfo(gitModulesPath))
- {
- WriteGitCommitMarkerFileForSubmodule(sourceDirPath, gitDirPath, dependency.Sha, submodule.Name, submodule.Path);
- }
- }
-
- private void WriteGitCommitMarkerFileForSubmodule(string sourceDirPath, string gitDirPath, string parentRepoSha, string submoduleName, string submodulePath)
- {
- var submoduleSha = GetSubmoduleCommit(gitDirPath, parentRepoSha, submodulePath);
- var headDirectory = Path.Combine(sourceDirPath, submodulePath, ".git");
- var headPath = Path.Combine(headDirectory, "HEAD");
- Directory.CreateDirectory(headDirectory);
- File.WriteAllText(headPath, submoduleSha);
- }
-
- private static void WriteMinimalMetadata(string repoPath, string repoUrl, string hash)
- {
- var fakeGitDirPath = Path.Combine(repoPath, ".git");
- var fakeGitConfigPath = Path.Combine(fakeGitDirPath, "config");
- var fakeGitHeadPath = Path.Combine(fakeGitDirPath, "HEAD");
-
- Directory.CreateDirectory(fakeGitDirPath);
- File.WriteAllText(fakeGitHeadPath, hash);
- File.WriteAllText(fakeGitConfigPath, $"[remote \"origin\"]{Environment.NewLine}url = \"{repoUrl}\"");
- }
-
-
- private string GetSubmoduleCommit(string gitDirPath, string parentRepoSha, string submodulePath)
- {
- var gitObjectList = RunGitCommand($"ls-tree {parentRepoSha} {submodulePath}", gitDir: gitDirPath);
- var submoduleRegex = new Regex(@"\d{6}\s+commit\s+(?[a-fA-F0-9]{40})\s+(.+)");
- var submoduleMatch = submoduleRegex.Match(gitObjectList);
- if (!submoduleMatch.Success)
- {
- throw new InvalidDataException($"Couldn't find a submodule commit in {gitObjectList} for {submodulePath}");
- }
- return submoduleMatch.Groups["submoduleSha"].Value;
- }
-
- private static void WritePropsFile(string filePath, Dictionary properties)
- {
- var content = new StringBuilder();
- content.AppendLine("");
- content.AppendLine("");
- content.AppendLine(" ");
- foreach (var propName in properties.Keys.OrderBy(k => k))
- {
- content.AppendLine($" <{propName}>{properties[propName]}{propName}>");
- }
- content.AppendLine(" ");
- content.AppendLine("");
- File.WriteAllText(filePath, content.ToString());
- }
-
- private class DerivedVersion
- {
- internal string OfficialBuildId { get; set; }
- internal string PreReleaseVersionLabel { get; set; }
- }
-
- private class SubmoduleInfo
- {
- internal string Name { get; set; }
- internal string Path { get; set; }
- }
- }
-}