From cecc728fb8aadc41647c24daed34a59186225acb Mon Sep 17 00:00:00 2001 From: Epsitha Ananth <47157394+epananth@users.noreply.github.com> Date: Mon, 24 Oct 2022 20:52:32 -0700 Subject: [PATCH] Generate SBOM for Fsharp (#14029) * Generate Sbom * pass ci flag * update * Sbom generation * Fix for trimming tests: Added nuget.org source + explicit source mapping for FSharp.Core * Update Build.ps1 Tweaks to handle useGlobalNugetCache Co-authored-by: Kevin Ransom (msft) Co-authored-by: Vlad Zarytovskii Co-authored-by: Kevin Ransom (msft) --- Build.cmd | 2 +- azure-pipelines.yml | 2 ++ eng/Build.ps1 | 7 ++++++- eng/RestoreInternal.cmd | 2 ++ eng/restore-internal-tools.yml | 13 +++++++++++++ .../SelfContained_Trimming_Test/NuGet.Config | 11 ++++++++++- .../SelfContained_Trimming_Test.fsproj | 5 ++++- 7 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 eng/RestoreInternal.cmd create mode 100644 eng/restore-internal-tools.yml diff --git a/Build.cmd b/Build.cmd index ad55484933d..e8af08f3935 100644 --- a/Build.cmd +++ b/Build.cmd @@ -1,2 +1,2 @@ @echo off -powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\build.ps1""" -build -restore %*" +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\build.ps1""" -build -restore %*" \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d739dc40ac2..df849372dd0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -118,6 +118,7 @@ stages: steps: - checkout: self clean: true + - template: /eng/restore-internal-tools.yml - script: eng\CIBuild.cmd -configuration $(_BuildConfig) -prepareMachine @@ -138,6 +139,7 @@ stages: /p:OfficialBuildId=$(BUILD.BUILDNUMBER) /p:PublishToSymbolServer=true /p:VisualStudioDropName=$(VisualStudioDropName) + /p:GenerateSbom=true - script: .\tests\EndToEndBuildTests\EndToEndBuildTests.cmd -c $(_BuildConfig) displayName: End to end build tests - task: PublishTestResults@2 diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 8670b785994..c2d58455868 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -45,6 +45,7 @@ param ( [switch]$deployExtensions, [switch]$prepareMachine, [switch]$useGlobalNuGetCache = $true, + [switch]$dontUseGlobalNuGetCache = $false, [switch]$warnAsError = $true, [switch][Alias('test')]$testDesktop, [switch]$testCoreClr, @@ -113,7 +114,7 @@ function Print-Usage() { Write-Host " -msbuildEngine Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)." Write-Host " -procdump Monitor test runs with procdump" Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build" - Write-Host " -useGlobalNuGetCache Use global NuGet cache." + Write-Host " -dontUseGlobalNuGetCache Do not use the global NuGet cache" Write-Host " -noVisualStudio Only build fsc and fsi as .NET Core applications. No Visual Studio required. '-configuration', '-verbosity', '-norestore', '-rebuild' are supported." Write-Host " -sourceBuild Simulate building for source-build." Write-Host " -skipbuild Skip building product" @@ -131,6 +132,10 @@ function Process-Arguments() { exit 0 } + if ($dontUseGlobalNugetCache -or $ci) { + $script:useGlobalNugetCache = $False + } + $script:nodeReuse = $False; if ($testAll) { diff --git a/eng/RestoreInternal.cmd b/eng/RestoreInternal.cmd new file mode 100644 index 00000000000..cdd42f2c499 --- /dev/null +++ b/eng/RestoreInternal.cmd @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0\common\build.ps1""" -build -restore %*" \ No newline at end of file diff --git a/eng/restore-internal-tools.yml b/eng/restore-internal-tools.yml new file mode 100644 index 00000000000..f71d0710e44 --- /dev/null +++ b/eng/restore-internal-tools.yml @@ -0,0 +1,13 @@ +steps: + - task: NuGetAuthenticate@0 + inputs: + nuGetServiceConnections: 'devdiv/dotnet-core-internal-tooling' + forceReinstallCredentialProvider: true + + - script: $(Build.SourcesDirectory)\eng\RestoreInternal.cmd + -ci + -projects $(Build.SourcesDirectory)/eng/common/internal/Tools.csproj + /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/RestoreInternal.binlog + /v:normal + displayName: Restore internal tools + condition: and(succeeded(), ne(variables['_skipRestoreInternalTools'], 'true')) \ No newline at end of file diff --git a/tests/projects/SelfContained_Trimming_Test/NuGet.Config b/tests/projects/SelfContained_Trimming_Test/NuGet.Config index 277ccdc4067..e8af19a856b 100644 --- a/tests/projects/SelfContained_Trimming_Test/NuGet.Config +++ b/tests/projects/SelfContained_Trimming_Test/NuGet.Config @@ -1,11 +1,12 @@ - + + @@ -13,4 +14,12 @@ + + + + + + + + diff --git a/tests/projects/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj b/tests/projects/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj index b60d71ac565..6654cf18e18 100644 --- a/tests/projects/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj +++ b/tests/projects/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj @@ -10,6 +10,8 @@ true + true + true true win-x64 @@ -29,7 +31,8 @@ - $(MSBuildThisFileDirectory)/../../../artifacts/packages/Release/Release + $(MSBuildThisFileDirectory)/../../../artifacts/packages/Release/Release; + https://api.nuget.org/v3/index.json;