@@ -10,61 +10,58 @@ steps:
1010- task : NuGetAuthenticate@1
1111 displayName : ' NuGet Authenticate'
1212
13- - task : PowerShell@2
14- displayName : Update WinAppSDK Versions
15- inputs :
16- filePath : ' $(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1'
17- arguments : >
18- -winAppSdkVersionNumber ${{ parameters.versionNumber }}
19- -useExperimentalVersion $${{ parameters.useExperimentalVersion }}
20- -rootPath "$(build.sourcesdirectory)"
21-
22- - script : echo $(WinAppSDKVersion)
23- displayName : ' Display WinAppSDK Version Found'
24-
2513- task : PowerShell@2
2614 displayName : ' Configure NuGet'
2715 inputs :
2816 targetType : ' inline'
2917 script : |
3018 $nugetConfigPath = "$(Build.SourcesDirectory)\nuget.config"
31- Write-Host "Modifying $nugetConfigPath to include local packages..."
19+ $localPackagesPath = "$(Build.SourcesDirectory)\localpackages\output"
20+
21+ # Ensure the directory exists so it's a valid source
22+ New-Item -ItemType Directory -Path $localPackagesPath -Force | Out-Null
3223
24+ Write-Host "Modifying $nugetConfigPath to include local packages..."
3325 [xml]$xml = Get-Content -Path $nugetConfigPath
3426
35- # Add localpackages source if it exists
36- $localPackagesPath = "$(Build.SourcesDirectory)\localpackages\output"
37- if (Test-Path $localPackagesPath) {
38- # Add source
39- $packageSourcesNode = $xml.configuration.packageSources
40- $addNode = $xml.CreateElement("add")
41- $addNode.SetAttribute("key", "localpackages")
42- $addNode.SetAttribute("value", $localPackagesPath)
43- $packageSourcesNode.AppendChild($addNode) | Out-Null
27+ # Add localpackages source
28+ $packageSourcesNode = $xml.configuration.packageSources
29+ $addNode = $xml.CreateElement("add")
30+ $addNode.SetAttribute("key", "localpackages")
31+ $addNode.SetAttribute("value", $localPackagesPath)
32+ $packageSourcesNode.AppendChild($addNode) | Out-Null
33+
34+ # Add mapping for WindowsAppSDK
35+ $packageSourceMappingNode = $xml.configuration.packageSourceMapping
36+ if ($packageSourceMappingNode) {
37+ $sourceNode = $xml.CreateElement("packageSource")
38+ $sourceNode.SetAttribute("key", "localpackages")
39+ $packageNode = $xml.CreateElement("package")
40+ $packageNode.SetAttribute("pattern", "Microsoft.WindowsAppSDK*")
41+ $sourceNode.AppendChild($packageNode) | Out-Null
4442
45- # Add mapping for WindowsAppSDK
46- $packageSourceMappingNode = $xml.configuration.packageSourceMapping
47- if ($packageSourceMappingNode) {
48- $sourceNode = $xml.CreateElement("packageSource")
49- $sourceNode.SetAttribute("key", "localpackages")
50- $packageNode = $xml.CreateElement("package")
51- $packageNode.SetAttribute("pattern", "Microsoft.WindowsAppSDK*")
52- $sourceNode.AppendChild($packageNode) | Out-Null
53-
54- # Insert before the existing mappings to prioritize (optional, but good practice)
55- if ($packageSourceMappingNode.HasChildNodes) {
56- $packageSourceMappingNode.InsertBefore($sourceNode, $packageSourceMappingNode.FirstChild) | Out-Null
57- } else {
58- $packageSourceMappingNode.AppendChild($sourceNode) | Out-Null
59- }
43+ # Insert before the existing mappings to prioritize
44+ if ($packageSourceMappingNode.HasChildNodes) {
45+ $packageSourceMappingNode.InsertBefore($sourceNode, $packageSourceMappingNode.FirstChild) | Out-Null
46+ } else {
47+ $packageSourceMappingNode.AppendChild($sourceNode) | Out-Null
6048 }
6149 }
6250
6351 $xml.Save($nugetConfigPath)
6452 Get-Content $nugetConfigPath
6553
66- - task : NuGetAuthenticate@1
67- displayName : ' NuGet Authenticate (After Config Change)'
54+ - task : PowerShell@2
55+ displayName : Update WinAppSDK Versions
56+ inputs :
57+ filePath : ' $(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1'
58+ arguments : >
59+ -winAppSdkVersionNumber ${{ parameters.versionNumber }}
60+ -useExperimentalVersion $${{ parameters.useExperimentalVersion }}
61+ -rootPath "$(build.sourcesdirectory)"
62+
63+ - script : echo $(WinAppSDKVersion)
64+ displayName : ' Display WinAppSDK Version Found'
6865
6966- task : NuGetCommand@2
7067 displayName : ' Restore NuGet packages'
0 commit comments