Skip to content

Commit

Permalink
Merge branch 'main' into windows-setting-language
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft authored Nov 15, 2024
2 parents b482a12 + 569b657 commit 9d56ef3
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ codeowners
github
https
Icm
markdownlint
microsoft
msftbot
numpy
Expand Down Expand Up @@ -39,3 +40,6 @@ ELSPROBLEMS
requ
whatif
pscustomobject
VGpu
wildcards
worktree
26 changes: 16 additions & 10 deletions .github/actions/spelling/expect/generic_terms.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
wildcards
ssh
AKV
Amd
usr
screenshots
Authenticode
automerge
currentstate
esrp
gtm
msft
NPH
Peet
rfc
screenshots
Scrollbars
Searchbox
VGpu
versioning
worktree
SFP
Signtool
sortby
msft
automerge
Workaround
ssh
usr
versioning
VGpu
4 changes: 1 addition & 3 deletions .github/actions/spelling/expect/software.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ vscode
Linux
dotnet
dotnettool
cspell
NUnit
reportgenerator
Toolpackage
markdownlint
markdownlint
153 changes: 153 additions & 0 deletions pipelines/azure-pipelines.publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# winget-dsc pipeline to publish module artifacts
name: '$(Build.DefinitionName)-$(Build.DefinitionVersion)-$(Date:yyyyMMdd)-$(Rev:r)'

trigger: none

parameters: # parameters are shown up in ADO UI in a build queue time

- name: moduleName
displayName: 'Name of the module to publish to the PSGallery'
type: string

- name: moduleVersion
displayName: 'Version of the module'
type: string

resources:
repositories:
- repository: self
type: git
ref: refs/heads/main
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-2022
os: windows
customBuildTags:
- ES365AIMigrationTooling
settings:
skipBuildTagsForGitHubPullRequests: true

stages:
- stage: Prepare
jobs:
- job: Prepare_Sign
displayName: Prepare and sign ${{ parameters.moduleName }}
steps:
- task: NuGetToolInstaller@1
displayName: 'Use NuGet 6.x'
inputs:
versionSpec: 6.x
- task: PowerShell@2
displayName: Replace module version
inputs:
targetType: inline
pwsh: true
script: |
$manifestContent = (Get-Content -path $(Build.SourcesDirectory)\resources\${{ parameters.moduleName }}\${{ parameters.moduleName }}.psd1 -Raw)
$newManifestContent = $manifestContent -replace "'0.1.0'", "'${{ parameters.moduleVersion }}'"
Set-Content -path $(Build.SourcesDirectory)\resources\${{ parameters.moduleName }}\${{ parameters.moduleName }}.psd1 -Value $newManifestContent
New-Item ToSign -Type Directory
Set-Content -path ToSign\${{ parameters.moduleName }}.psd1 -Value $newManifestContent
Get-Content ToSign\${{ parameters.moduleName }}.psd1 -Raw
Copy-Item -Path "$(Build.SourcesDirectory)\resources\${{ parameters.moduleName }}\${{ parameters.moduleName }}.psm1" -Destination "ToSign\${{ parameters.moduleName }}.psm1" -Force
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
displayName: 'Sign manifest'
inputs:
ConnectedServiceName: AppInstallerESRPCodeSigning
AppRegistrationClientId: '32216f16-efc9-4013-9fae-c6a2c54a3fc0'
AppRegistrationTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
AuthAKVName: PeetDevOpsKeyVault
AuthCertName: ESRPAuth
AuthSignCertName: ESRPRequestSigning
FolderPath: '$(System.DefaultWorkingDirectory)\ToSign\'
Pattern: '*'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode" : "CP-230012",
"OperationCode" : "SigntoolSign",
"Parameters" : {
"OpusName" : "Microsoft",
"OpusInfo" : "http://www.microsoft.com",
"FileDigest" : "/fd \"SHA256\"",
"PageHash" : "/NPH",
"TimeStamp" : "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName" : "sign",
"ToolVersion" : "1.0"
},
{
"KeyCode" : "CP-230012",
"OperationCode" : "SigntoolVerify",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
}
]
- task: PowerShell@2
displayName: Copy Signed Files and Validate signature
inputs:
targetType: inline
pwsh: true
script: |
New-Item ToPublish\${{ parameters.moduleName }} -Type Directory
$moduleFolder = "ToPublish\${{ parameters.moduleName }}"
Copy-Item -Path "ToSign\${{ parameters.moduleName }}.psm1" -Destination "ToPublish\${{ parameters.moduleName }}\${{ parameters.moduleName }}.psm1" -Force
Copy-Item -Path "ToSign\${{ parameters.moduleName }}.psd1" -Destination "ToPublish\${{ parameters.moduleName }}\${{ parameters.moduleName }}.psd1" -Force
$notValid = Get-ChildItem $moduleFolder -Recurse -Attributes !Directory | Get-AuthenticodeSignature | where { $_.Status -ne 'Valid' }
if ($null -ne $notValid)
{
$notValid
throw "A file is not signed"
}
- task: CopyFiles@2
displayName: Copy files to be published to staging directory
inputs:
SourceFolder: ToPublish\${{ parameters.moduleName }}
targetFolder: $(Build.ArtifactStagingDirectory)/${{ parameters.moduleName }}
flattenFolders: true
contents: |
*.psm1
*.psd1
- task: 1ES.PublishPipelineArtifact@1
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/${{ parameters.moduleName }}
artifactName: ${{ parameters.moduleName }}
displayName: Publish Module Artifact

- stage: Publish
displayName: Manual Approval
trigger: manual
jobs:
- job: PublishToGallery
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: current
artifactName: ${{ parameters.moduleName }}
targetPath: $(System.DefaultWorkingDirectory)/ModuleToPublish/${{ parameters.moduleName }}
itemPattern: |
*.psm1
*.psd1
- pwsh: |
$moduleFolder = "$(System.DefaultWorkingDirectory)/ModuleToPublish/${{ parameters.moduleName }}"
Get-ChildItem -Path $moduleFolder -Recurse
$moduleFolderPath = (Resolve-Path $moduleFolder).Path
Publish-Module -Path $moduleFolderPath -Repository PSGallery -NuGetApiKey $env:api_key -verbose
displayName: Publish ${{ parameters.moduleName }}'
env:
api_key: $(DscSamplesNugetApiKey)
17 changes: 9 additions & 8 deletions resources/Help/Microsoft.Dotnet.Dsc/DotNetToolPackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ The `DotNetToolPackage` DSC Resource allows you to install, update, and uninstal

## PARAMETERS

| **Parameter** | **Attribute** | **DataType** | **Description** | **Allowed Values** |
| ------------------- | ------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| `PackageId` | Key | String | The ID of the .NET tool package to manage. | N/A |
| `Version` | Optional | String | The version of the .NET tool package to install. If not specified, the latest version will be installed. | N/A |
| `Commands` | Optional | String[] | An array of commands provided by the .NET tool package. | N/A |
| `Prerelease` | Optional | Boolean | Indicates whether to include prerelease versions of the .NET tool package. The default value is `$false`. | `$true`, `$false` |
| `ToolPathDirectory` | Optional | String | The directory where the .NET tool package will be installed. If not specified, the package will be installed globally. | Use custom directory when you have |
| `Exist` | Optional | Boolean | Indicates whether the package should exist. Defaults to `$true`. | `$true` or `$false` |
| **Parameter** | **Attribute** | **DataType** | **Description** | **Allowed Values** |
| ------------------- | ------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| `PackageId` | Key | String | The ID of the .NET tool package to manage. | N/A |
| `Version` | Optional | String | The version of the .NET tool package to install. If not specified, the latest version will be installed. | N/A |
| `Commands` | Optional | String[] | An array of commands provided by the .NET tool package. | N/A |
| `Prerelease` | Optional | Boolean | Indicates whether to include prerelease versions of the .NET tool package. The default value is `$false`. Note: If the prerelease version is lower than the current version, the highest version will be installed. | `$true`, `$false` |
| `ToolPathDirectory` | Optional | String | The directory where the .NET tool package will be installed. If not specified, the package will be installed globally. | Use custom directory when you have |
| `Exist` | Optional | Boolean | Indicates whether the package should exist. Defaults to `$true`. | `$true` or `$false` |

## EXAMPLES

Expand Down Expand Up @@ -59,4 +59,5 @@ Invoke-DscResource -ModuleName Microsoft.DotNet.Dsc -Name DotNetToolPackage -Met
}
# This example installs the prerelease version of the .NET tool package 'PowerShell' in the 'C:\tools' directory.
# NOTE: When the version in the feed is for example v7.4.5-preview1 and the highest is v7.4.6, the highest will be installed.
```
1 change: 1 addition & 0 deletions resources/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ $DotNetCliPath = Get-DotNetPath
}
This example installs the prerelease version of the .NET tool package 'PowerShell' in the 'C:\tools' directory.
NOTE: When the version in the feed is for example v7.4.5-preview1 and the highest is v7.4.6, the highest will be installed.
#>
[DSCResource()]
class DotNetToolPackage {
Expand Down
4 changes: 2 additions & 2 deletions resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ function Invoke-VSCode {
[string]$Command
)

$stdErrTempFile = "$env:TEMP\$((New-Guid).Guid)"
$stdOutTempFile = "$env:TEMP\$((New-Guid).Guid)"
$stdErrTempFile = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath (New-Guid).Guid
$stdOutTempFile = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath (New-Guid).Guid
$invocationSuccess = $true

$processParams = @{
Expand Down
15 changes: 1 addition & 14 deletions tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ Describe 'DSC operation capabilities' {
$finalState.Version | Should -Not -BeNullOrEmpty
}

It 'Sets desired package with prerelease' -Skip:(!$IsWindows) {
$parameters = @{
PackageId = 'dotnet-ef'
PreRelease = $true
}

Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters

$finalState = Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Get -Property $parameters
$finalState.PackageId | Should -Be $parameters.PackageId
$finalState.PreRelease | Should -BeTrue
}

It 'Sets desired package with version' -Skip:(!$IsWindows) {
$parameters = @{
PackageId = 'dotnet-reportgenerator-globaltool'
Expand Down Expand Up @@ -99,7 +86,7 @@ Describe 'DSC operation capabilities' {
It 'Exports resources' -Skip:(!$IsWindows) {
$obj = [DotNetToolPackage]::Export()

$obj.PackageId.Contains('dotnet-ef') | Should -Be $true
$obj.PackageId.Contains('gitversion.tool') | Should -Be $true
$obj.PackageId.Contains('dotnet-reportgenerator-globaltool') | Should -Be $true
}

Expand Down

0 comments on commit 9d56ef3

Please sign in to comment.