-
Notifications
You must be signed in to change notification settings - Fork 317
[DRAFT] Use global.json to restrict .NET SDK use #3797
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,16 +60,14 @@ jobs: | |
| - pwsh: 'Get-ChildItem env: | Sort-Object Name' | ||
| displayName: '[Debug] List Environment Variables' | ||
|
|
||
| - template: ../steps/ensure-dotnet-version.yml@self | ||
| parameters: | ||
| packageType: sdk | ||
| version: '10.0' | ||
|
|
||
| - template: ../steps/ensure-dotnet-version.yml@self | ||
| parameters: | ||
| packageType: runtime | ||
| version: '9.0' | ||
| # Install whichever .NET SDKs are specified in our global.json. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code coverage only runs on Windows x64, so we don't need the special |
||
| - task: UseDotNet@2 | ||
| displayName: Install .NET SDKs | ||
| inputs: | ||
| packageType: sdk | ||
| useGlobalJson: true | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Install additional dotnet tools. | ||
| - pwsh: | | ||
| dotnet tool install --global dotnet-coverage | ||
| dotnet tool install --global dotnet-reportgenerator-globaltool | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,11 @@ parameters: | |
| # The timeout, in minutes, for this job. | ||
| - name: timeout | ||
| type: number | ||
|
|
||
| # True if this is an ARM64 job. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to detect ARM64 - we already know explicitly which agent images are ARM64 and we can simply set this flag in those cases. |
||
| - name: isArm64 | ||
| type: boolean | ||
| default: false | ||
|
|
||
| jobs: | ||
| - job: ${{ format('{0}', coalesce(parameters.jobDisplayName, parameters.image, 'unknown_image')) }} | ||
|
|
@@ -102,6 +107,58 @@ jobs: | |
| value: '$(dotnetx86Path)' | ||
|
|
||
| steps: | ||
|
|
||
| # Install .NET SDKs and runtimes. These may be needed for the pre-build | ||
| # steps. | ||
| # | ||
| # We can use the standard UseDotNet@2 task for non-ARM64 jobs. | ||
| - ${{ if eq(parameters.isArm64, false) }}: | ||
| - task: UseDotNet@2 | ||
| displayName: Install .NET SDKs | ||
| inputs: | ||
| packageType: sdk | ||
| useGlobalJson: true | ||
|
|
||
| - task: UseDotNet@2 | ||
| displayName: Install .NET 9 Runtime | ||
| inputs: | ||
| packageType: runtime | ||
| version: 9.x | ||
|
|
||
| - task: UseDotNet@2 | ||
| displayName: Install .NET 8 Runtime | ||
| inputs: | ||
| packageType: runtime | ||
| version: 8.x | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # For ARM64, we need to use our custom step to work around a bug in | ||
| # UseDotNet@2: | ||
| # | ||
| # [BUG]: UseDotNet task installs x86 build | ||
| # https://github.com/microsoft/azure-pipelines-tasks/issues/20300 | ||
| # | ||
| - ${{ else }}: | ||
| - template: ../../../steps/install-dotnet-arm64.yml@self | ||
| parameters: | ||
| debug: ${{ parameters.debug }} | ||
| installType: SDK | ||
| # GOTCHA: We always use global.json for SDK version except on ARM64, | ||
| # where we have to specify it here. This must be kept synchronized with | ||
| # the SDK version in global.json. | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| version: 10.0 | ||
|
|
||
| - template: ../../../steps/install-dotnet-arm64.yml@self | ||
| parameters: | ||
| debug: ${{ parameters.debug }} | ||
| installType: Runtime | ||
| version: 9.0 | ||
|
|
||
| - template: ../../../steps/install-dotnet-arm64.yml@self | ||
| parameters: | ||
| debug: ${{ parameters.debug }} | ||
| installType: Runtime | ||
| version: 8.0 | ||
|
|
||
| - ${{ if ne(parameters.prebuildSteps, '') }}: | ||
| - ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration | ||
|
|
||
|
|
@@ -121,6 +178,12 @@ jobs: | |
| } | ||
| displayName: 'Verify Password' | ||
|
|
||
| - ${{ if eq(parameters.buildType, 'Project') }}: | ||
| - template: ../steps/ci-project-build-step.yml@self | ||
| parameters: | ||
| build: allNoDocs | ||
| buildConfiguration: ${{ parameters.buildConfiguration }} | ||
|
|
||
| - ${{ if ne(parameters.configProperties, '{}') }}: | ||
| - template: ../steps/update-config-file-step.yml@self # update config.json file | ||
| parameters: | ||
|
|
@@ -253,33 +316,28 @@ jobs: | |
| # it should be acceptable to just install a specific version in all cases. | ||
| # @TODO: This setup is very confusing. Ideally we should just be utilizing the dotnet installation | ||
| # earlier in the job. There has to be a cleaner way of doing this. | ||
| # As it stands now, we install dotnet LTS if we're running netfx tests, and the appropriate netX | ||
| # version if we're running netcore tests. Technically LTS is not supported by the UseDotNet task | ||
| # but we know we're using install-dotnet since we're on windows (for now ... this will not work | ||
| # forever and needs a serious rethinking). | ||
| - ${{ if ne(variables['dotnetx86RootPath'], '') }}: | ||
| - ${{ if startswith(parameters.targetFramework, 'net4')}}: | ||
| - template: ../steps/ensure-dotnet-version.yml | ||
| parameters: | ||
| installDir: "$(dotnetx86RootPath)" | ||
| packageType: "sdk" | ||
| usePreview: "false" | ||
| version: "LTS" | ||
| windowsArchitecture: "x86" | ||
| - ${{ else }}: | ||
| - script: | | ||
| set FrameworkVersion=${{ parameters.targetFramework }} | ||
| echo %FrameworkVersion% | ||
| set TrimmedFrameworkVersion=%FrameworkVersion:~3% | ||
| echo %TrimmedFrameworkVersion% | ||
| echo ##vso[task.setvariable variable=netVersionX86]%TrimmedFrameworkVersion% | ||
| displayName: "Trim dotnet version" | ||
| - template: ../steps/ensure-dotnet-version.yml | ||
| parameters: | ||
| installDir: "$(dotnetx86RootPath)" | ||
| packageType: "sdk" | ||
| usePreview: "false" | ||
| version: $(netVersionX86) | ||
| # Install whichever .NET SDKs are specified in our global.json. | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - task: UseDotNet@2 | ||
| displayName: Install .NET SDKs | ||
| inputs: | ||
| installationPath: $(dotnetx86RootPath) | ||
| packageType: sdk | ||
| useGlobalJson: true | ||
| env: | ||
| # Override the architecture to install for x86. | ||
| PROCESSOR_ARCHITECTURE: x86 | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Install the .NET 8.0 runtime to run tests that target it. | ||
| - task: UseDotNet@2 | ||
| displayName: Install .NET 8.0 Runtime | ||
| inputs: | ||
| installationPath: $(dotnetx86RootPath) | ||
| packageType: runtime | ||
| version: 8.x | ||
| env: | ||
| # Override the architecture to install for x86. | ||
| PROCESSOR_ARCHITECTURE: x86 | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - template: ../steps/run-all-tests-step.yml@self | ||
| parameters: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,34 +25,23 @@ parameters: | |
| - MSS | ||
|
|
||
| steps: | ||
| - task: DownloadSecureFile@1 | ||
| displayName: 'Download Key Pair' | ||
| inputs: | ||
| secureFile: netfxKeypair.snk | ||
| retryCount: 5 | ||
|
|
||
| - task: UseDotNet@2 | ||
| displayName: 'Use .NET 10.x sdk' | ||
| inputs: | ||
| packageType: sdk | ||
| version: '10.x' | ||
|
|
||
| - task: UseDotNet@2 | ||
| displayName: 'Use .NET 9.x runtime' | ||
| inputs: | ||
| packageType: runtime | ||
| version: '9.x' | ||
|
|
||
| - task: UseDotNet@2 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need a .NET 8 runtime to build things. We would only need it to run tests, which doesn't happen as part of this pipeline tree. |
||
| displayName: 'Install .NET 8.x runtime' | ||
| inputs: | ||
| packageType: runtime | ||
| version: '8.x' | ||
| - task: DownloadSecureFile@1 | ||
| displayName: 'Download Key Pair' | ||
| inputs: | ||
| secureFile: netfxKeypair.snk | ||
| retryCount: 5 | ||
|
|
||
| - ${{ if eq(parameters.product, 'MDS') }}: | ||
| - task: MSBuild@1 | ||
| displayName: 'BuildAllConfigurations using build.proj' | ||
| # Install whichever .NET SDKs are specified in our global.json. | ||
| - task: UseDotNet@2 | ||
| displayName: Install .NET SDKs | ||
| inputs: | ||
| solution: '**/build.proj' | ||
| configuration: '${{parameters.buildConfiguration }}' | ||
| msbuildArguments: '-p:AssemblyFileVersion=${{parameters.AssemblyFileVersion }} -t:BuildAllConfigurations -p:GenerateNuget=false -p:SigningKeyPath=$(Agent.TempDirectory)\netfxKeypair.snk' | ||
| packageType: sdk | ||
| useGlobalJson: true | ||
|
|
||
| - ${{ if eq(parameters.product, 'MDS') }}: | ||
| - task: MSBuild@1 | ||
| displayName: 'BuildAllConfigurations using build.proj' | ||
| inputs: | ||
| solution: '**/build.proj' | ||
| configuration: '${{parameters.buildConfiguration }}' | ||
| msbuildArguments: '-p:AssemblyFileVersion=${{parameters.AssemblyFileVersion }} -t:BuildAllConfigurations -p:GenerateNuget=false -p:SigningKeyPath=$(Agent.TempDirectory)\netfxKeypair.snk' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,24 +25,6 @@ parameters: | |
| - Package | ||
|
|
||
| steps: | ||
| - template: ensure-dotnet-version.yml | ||
| parameters: | ||
| packageType: sdk | ||
| usePreview: false | ||
| version: 10.0 | ||
|
|
||
| - template: ensure-dotnet-version.yml | ||
| parameters: | ||
| packageType: runtime | ||
| usePreview: false | ||
| version: 9.0 | ||
|
|
||
| - template: ensure-dotnet-version.yml | ||
| parameters: | ||
| packageType: runtime | ||
| usePreview: false | ||
| version: 8.0 | ||
|
|
||
| - ${{if eq(parameters.debug, true)}}: | ||
| - powershell: | | ||
| Get-ChildItem env: | Sort-Object Name | ||
|
|
@@ -61,9 +43,3 @@ steps: | |
| parameters: | ||
| downloadedNugetPath: $(Pipeline.Workspace)\${{parameters.artifactName }} | ||
| debug: ${{ parameters.debug }} | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - ${{ else }}: # project | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was weird for the pre-build step to run a build. This has been moved out to the calling template, along with the installation of the SDKs and Runtimes. |
||
| - template: ci-project-build-step.yml@self | ||
| parameters: | ||
| build: allNoDocs | ||
| buildConfiguration: ${{ parameters.buildConfiguration }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,21 +37,6 @@ parameters: | |
| - allNoDocs | ||
|
|
||
| steps: | ||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - template: ./ensure-dotnet-version.yml@self | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This now happens earlier in the template tree. |
||
| parameters: | ||
| packageType: 'sdk' | ||
| version: '10.0' | ||
|
|
||
| - template: ./ensure-dotnet-version.yml@self | ||
| parameters: | ||
| packageType: 'runtime' | ||
| version: '9.0' | ||
|
|
||
| - template: ./ensure-dotnet-version.yml@self | ||
| parameters: | ||
| packageType: 'runtime' | ||
| version: '8.0' | ||
|
|
||
| - ${{ if or(eq(parameters.operatingSystem, 'Windows'), eq(parameters.operatingSystem, 'deferedToRuntime')) }}: | ||
| - ${{ if or(eq(parameters.build, 'MDS'), eq(parameters.build, 'all'), eq(parameters.build, 'allNoDocs')) }}: | ||
| - task: MSBuild@1 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.