Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 85 additions & 21 deletions dev/Templates/Dotnet/Test-DotnetNewTemplates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -453,31 +453,95 @@ function Get-LatestOfficialWasdkVersion {
$sourceFeed = 'https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/flat2/microsoft.windowsappsdk/index.json'
$excludedVersionPrefixes = @('2.63.')
$token = $env:SYSTEM_ACCESSTOKEN
if ([string]::IsNullOrWhiteSpace($token)) {
Write-Warning "SYSTEM_ACCESSTOKEN is not set; cannot query the package source for versions."
return $null
}
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$response = Invoke-RestMethod -Uri $sourceFeed -Headers @{ Authorization = "Bearer $token" } -TimeoutSec 30 -ErrorAction Stop
$latest = $null
foreach ($v in $response.versions) {
if ($v -match '-') { continue } # skip prerelease
$excluded = $false
foreach ($p in $excludedVersionPrefixes) { if ($v.StartsWith($p)) { $excluded = $true; break } }
if ($excluded) { continue }
$parsed = $null
if (-not [version]::TryParse($v, [ref]$parsed)) { continue }
if (($null -eq $latest) -or ($parsed -gt $latest.Ver)) {
$latest = [pscustomobject]@{ Raw = $v; Ver = $parsed }
# SYSTEM_ACCESSTOKEN is a pipeline variable. Use nuget CLI when running outside of pipeline runs
if ([string]::IsNullOrWhiteSpace($token)) {
Write-Warning "SYSTEM_ACCESSTOKEN is not set; cannot query package source for latest official Microsoft.WindowsAppSDK version. Using NuGet CLI instead"
$packageId = 'Microsoft.WindowsAppSDK'
$sourceFeed = 'https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json'
$json = & dotnet package search $packageId `
--source $sourceFeed `
--exact-match `
--format json `
--verbosity quiet

if ($LASTEXITCODE -ne 0) {
throw "dotnet package search failed with exit code $LASTEXITCODE."
}
}
if ($latest) {
Write-Host "Latest official Microsoft.WindowsAppSDK = $($latest.Raw) (excluded prerelease and $($excludedVersionPrefixes -join ', ')*)"

$response = $json | ConvertFrom-Json

$problems = @()

if ($response.PSObject.Properties['problems']) {
$problems += @($response.problems)
}

foreach ($result in @($response.searchResult)) {
if ($result.PSObject.Properties['problems']) {
$problems += @($result.problems)
}
}

if ($problems.Count -gt 0) {
throw ($problems | ForEach-Object { $_.text } | Join-String -Separator "`n")
}

$versions = foreach ($result in @($response.searchResult)) {
foreach ($package in @($result.packages)) {
if ($package.id -ine $packageId) {
continue
}

if ($package.PSObject.Properties['version']) {
$package.version
}
elseif ($package.PSObject.Properties['latestVersion']) {
$package.latestVersion
}
}
}
$latest = $versions |
Where-Object {
$version = $_
-not ($excludedVersionPrefixes | Where-Object {
$version.StartsWith($_)
})
} |
ForEach-Object {
[pscustomobject]@{
Raw = $_
Ver = [version]$_
}
} |
Sort-Object Ver -Descending |
Select-Object -First 1

return $latest.Raw
}
Write-Warning "No official Microsoft.WindowsAppSDK version found on the package source."
return $null
else
{
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$response = Invoke-RestMethod -Uri $sourceFeed -Headers @{ Authorization = "Bearer $token" } -TimeoutSec 30 -ErrorAction Stop
$latest = $null
foreach ($v in $response.versions) {
if ($v -match '-') { continue } # skip prerelease
$excluded = $false
foreach ($p in $excludedVersionPrefixes) { if ($v.StartsWith($p)) { $excluded = $true; break } }
if ($excluded) { continue }
$parsed = $null
if (-not [version]::TryParse($v, [ref]$parsed)) { continue }
if (($null -eq $latest) -or ($parsed -gt $latest.Ver)) {
$latest = [pscustomobject]@{ Raw = $v; Ver = $parsed }
}
}
if ($latest) {
Write-Host "Latest official Microsoft.WindowsAppSDK = $($latest.Raw) (excluded prerelease and $($excludedVersionPrefixes -join ', ')*)"
return $latest.Raw
}
Write-Warning "No official Microsoft.WindowsAppSDK version found on the package source."
return $null
}
}
catch {
Write-Warning "Failed to query the package source for versions: $($_.Exception.Message)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="$WindowsSdkBuildToolsVersion$" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="$WindowsAppSdkVersion$" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools.WinApp" Version="$WindowsSdkBuildToolsWinAppVersion$" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="$ext_WindowsSdkBuildToolsVersion$" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="$ext_WindowsAppSdkVersion$" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools.WinApp" Version="$ext_WindowsSdkBuildToolsWinAppVersion$" />
</ItemGroup>

<!-- Publish Properties -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@

<PropertyGroup>
<ProjectGuid>$guid1$</ProjectGuid>
<TargetPlatformVersion>$targetplatformversion$</TargetPlatformVersion>
<TargetPlatformMinVersion>$targetplatformminversion$</TargetPlatformMinVersion>
<TargetPlatformVersion>$ext_targetplatformversion$</TargetPlatformVersion>
<TargetPlatformMinVersion>$ext_targetplatformminversion$</TargetPlatformMinVersion>
<AssetTargetFallback>$ext_DotNetVersion$-windows$(TargetPlatformVersion);$(AssetTargetFallback)</AssetTargetFallback>
<DefaultLanguage>$currentuiculturename$</DefaultLanguage>
$if$($includeKeyFile$==true)
$if$($ext_includeKeyFile$==true)
<PackageCertificateKeyFile>$projectname$_TemporaryKey.pfx</PackageCertificateKeyFile>
$endif$
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
Expand All @@ -56,7 +56,7 @@
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
$if$($includeKeyFile$==true)
$if$($ext_includeKeyFile$==true)
<None Include="$projectname$_TemporaryKey.pfx" />
$endif$
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,9 @@
<ProjectItem ReplaceParameters="false" TargetFileName="Images\Wide310x150Logo.scale-200.png">Wide310x150Logo.scale-200.png</ProjectItem>
</Project>
</TemplateContent>
<WizardExtension>
<Assembly>Microsoft.VisualStudio.Universal.TemplateWizards, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.Universal.TemplateWizards.PlatformVersion.Wizard</FullClassName>
</WizardExtension>
<WizardExtension>
<!-- Generates Publisher name for appxmanifest -->
<Assembly>Microsoft.VisualStudio.WinRT.TemplateWizards, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.WinRT.TemplateWizards.UpdatePublisherInManifestWizard</FullClassName>
</WizardExtension>
<WizardData>
<MinSupportedVersion>10.0.17763.0</MinSupportedVersion>
<SkipXamlCompilerCheck>true</SkipXamlCompilerCheck>
<UseWindowsSdkBuildToolsPackage>true</UseWindowsSdkBuildToolsPackage>
<UseSdkFallbackFile>true</UseSdkFallbackFile>
</WizardData>
</VSTemplate>
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,23 @@
<TemplateContent PreferedSolutionConfiguration="Debug|x64">
<CustomParameters>
<CustomParameter Name="$DotNetVersion$" Value="FIXME-Verify-Directory.Build.Targets-XmlPoke-Queries"/>
<CustomParameter Name="$WindowsAppSdkVersion$" Value="*" />
<CustomParameter Name="$WindowsSdkBuildToolsVersion$" Value="*" />
<CustomParameter Name="$WindowsSdkBuildToolsWinAppVersion$" Value="*" />
</CustomParameters>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$projectname$ (Package)" CopyParameters="true">WapProj\WinUI.Desktop.Cs.WapProj.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$" CopyParameters="true">BlankApp\WinUI.Desktop.Cs.BlankApp.vstemplate</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
<WizardExtension>
<Assembly>Microsoft.VisualStudio.Universal.TemplateWizards, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.Universal.TemplateWizards.PlatformVersion.Wizard</FullClassName>
</WizardExtension>
<WizardData>
<MinSupportedVersion>10.0.17763.0</MinSupportedVersion>
<SkipXamlCompilerCheck>true</SkipXamlCompilerCheck>
<UseWindowsSdkBuildToolsPackage>true</UseWindowsSdkBuildToolsPackage>
<UseSdkFallbackFile>true</UseSdkFallbackFile>
</WizardData>
</VSTemplate>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<Identity
Name="$guid9$"
Publisher="$XmlEscapedPublisherDistinguishedName$"
Publisher="$ext_XmlEscapedPublisherDistinguishedName$"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="$guid9$" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@

<PropertyGroup>
<ProjectGuid>$guid1$</ProjectGuid>
<TargetPlatformVersion>$targetplatformversion$</TargetPlatformVersion>
<TargetPlatformMinVersion>$targetplatformminversion$</TargetPlatformMinVersion>
<TargetPlatformVersion>$ext_targetplatformversion$</TargetPlatformVersion>
<TargetPlatformMinVersion>$ext_targetplatformminversion$</TargetPlatformMinVersion>
<DefaultLanguage>$currentuiculturename$</DefaultLanguage>
$if$($includeKeyFile$==true)
$if$($ext_includeKeyFile$==true)
<PackageCertificateKeyFile>$projectname$_TemporaryKey.pfx</PackageCertificateKeyFile>
$endif$
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
Expand All @@ -56,7 +56,7 @@
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
$if$($includeKeyFile$==true)
$if$($ext_includeKeyFile$==true)
<None Include="$projectname$_TemporaryKey.pfx" />
$endif$
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,8 @@
<CustomParameter Name="$NuGetPackages$" Value="Microsoft.WindowsAppSDK;Microsoft.Windows.SDK.BuildTools"/>
</CustomParameters>
</TemplateContent>
<WizardExtension>
<Assembly>Microsoft.VisualStudio.Universal.TemplateWizards, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.Universal.TemplateWizards.PlatformVersion.Wizard</FullClassName>
</WizardExtension>
<WizardExtension>
<!-- Generates Publisher name for appxmanifest -->
<Assembly>Microsoft.VisualStudio.WinRT.TemplateWizards, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.WinRT.TemplateWizards.UpdatePublisherInManifestWizard</FullClassName>
</WizardExtension>
<WizardExtension>
<Assembly>WindowsAppSDK.Cpp.Extension.Dev17, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
<FullClassName>WindowsAppSDK.TemplateUtilities.NuGetPackageInstaller</FullClassName>
</WizardExtension>
<WizardData>
<MinSupportedVersion>10.0.17763.0</MinSupportedVersion>
<SkipXamlCompilerCheck>true</SkipXamlCompilerCheck>
</WizardData>
</VSTemplate>
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,18 @@
<ProjectTemplateLink ProjectName="$projectname$ (Package)" CopyParameters="true">WapProj\WinUI.Desktop.CppWinRT.WapProj.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$" CopyParameters="true">BlankApp\WinUI.Desktop.CppWinRT.BlankApp.vstemplate</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</TemplateContent>
<WizardExtension>
<!-- Generates Publisher name for appxmanifest -->
<Assembly>Microsoft.VisualStudio.WinRT.TemplateWizards, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.WinRT.TemplateWizards.UpdatePublisherInManifestWizard</FullClassName>
</WizardExtension>
<WizardExtension>
<Assembly>Microsoft.VisualStudio.Universal.TemplateWizards, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.Universal.TemplateWizards.PlatformVersion.Wizard</FullClassName>
</WizardExtension>
<WizardData>
<MinSupportedVersion>10.0.17763.0</MinSupportedVersion>
<SkipXamlCompilerCheck>true</SkipXamlCompilerCheck>
</WizardData>
</VSTemplate>
56 changes: 53 additions & 3 deletions dev/Templates/VSIX/build-local-VSIX-package/Build-VSIX-Local.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
.PARAMETER SkipRestore
Skip NuGet restore (useful if you've already restored).

.PARAMETER MsBuildVersion
Visual Studio version to target for MSBuild. Default: 17 (Visual Studio 2022).
Set to 18 for Visual Studio 2026.

.EXAMPLE
.\Build-VSIX-Local.ps1
# Build the LocalDev VSIX (default). Then install with .\Install-LocalDev-VSIX.ps1
Expand Down Expand Up @@ -82,7 +86,10 @@ param(

[string]$OptionalVSIXVersion = "",

[switch]$SkipRestore
[switch]$SkipRestore,

[ValidateSet(17, 18)]
[double]$MsBuildVersion = 17
)

Set-StrictMode -Version 2.0
Expand Down Expand Up @@ -122,9 +129,10 @@ function Find-MSBuild {
exit 1
}

$msbuildPath = & $vswherePath -latest -requires Microsoft.Component.MSBuild -find "MSBuild\**\Bin\MSBuild.exe" 2>$null | Select-Object -First 1
$range = '[{0},{1})' -f $MsBuildVersion, ($MsBuildVersion + 1)
$msbuildPath = & $vswherePath -version $range -requires Microsoft.Component.MSBuild -find "MSBuild\**\Bin\MSBuild.exe" 2>$null | Select-Object -First 1
Comment thread
lauren-ciha marked this conversation as resolved.
if (-not $msbuildPath -or -not (Test-Path $msbuildPath)) {
Write-Err "MSBuild.exe not found. Please install Visual Studio 2022+ with the '.NET desktop development' workload."
Write-Err "MSBuild.exe not found. Please install Visual Studio $MsBuildVersion with the '.NET desktop development' workload."
exit 1
}

Expand Down Expand Up @@ -420,6 +428,44 @@ function Invoke-MSBuildBuild {
}
}

function Test-VsixContainsTemplates {
param(
[string]$Path
)

Add-Type -AssemblyName System.IO.Compression.FileSystem

$archive = [System.IO.Compression.ZipFile]::OpenRead($Path)
try {
$projectTemplates = @(
$archive.Entries | Where-Object {
$_.FullName.StartsWith("ProjectTemplates/", [System.StringComparison]::OrdinalIgnoreCase) -and
$_.FullName.EndsWith(".vstemplate", [System.StringComparison]::OrdinalIgnoreCase)
}
)
$itemTemplates = @(
$archive.Entries | Where-Object {
$_.FullName.StartsWith("ItemTemplates/", [System.StringComparison]::OrdinalIgnoreCase) -and
$_.FullName.EndsWith(".vstemplate", [System.StringComparison]::OrdinalIgnoreCase)
}
)

if ($projectTemplates.Count -eq 0 -or $itemTemplates.Count -eq 0) {
Write-Err "VSIX template validation failed: $Path"
Write-Err " Project templates: $($projectTemplates.Count)"
Write-Err " Item templates : $($itemTemplates.Count)"
Write-Err "The selected Visual Studio/MSBuild toolset may not support packaging these templates."
return $false
}

Write-Step "Verified templates in $($archive.Entries.Count)-entry VSIX: $($projectTemplates.Count) project, $($itemTemplates.Count) item"
return $true
}
finally {
$archive.Dispose()
}
}

function Copy-VsixOutput {
param(
[string]$DeploymentType
Expand All @@ -446,6 +492,10 @@ function Copy-VsixOutput {
foreach ($vsix in $vsixFiles) {
if (-not $seen.ContainsKey($vsix.Name)) {
$seen[$vsix.Name] = $vsix
if (-not (Test-VsixContainsTemplates -Path $vsix.FullName)) {
exit 1
}

# Rename to include version: WindowsAppSDK.Cs.Extension.Dev17.Component.vsix
# -> WindowsAppSDK.Cs.Extension.Dev17.Component.99.2026.0416.1640.vsix
$newName = $vsix.BaseName + ".$OptionalVSIXVersion.vsix"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
.PARAMETER UninstallFirst
Run VSIXInstaller /uninstall before installing for a clean reinstall.

.PARAMETER MsBuildVersion
Visual Studio version to target for MSBuild. Default: 17 (Visual Studio 2022).
Set to 18 for Visual Studio 2026.

.EXAMPLE
.\build-install-localdev-vsix.ps1
# Build + install LocalDev C# + C++ to all VS 17+.
Expand All @@ -44,7 +48,10 @@ param(

[string]$VsVersionRange = '[17.0,)',

[switch]$UninstallFirst
[switch]$UninstallFirst,

[ValidateSet(17, 18)]
[double]$MsBuildVersion = 17
)

Set-StrictMode -Version 2.0
Expand Down Expand Up @@ -86,7 +93,7 @@ if ($SkipBuild) {
}
Push-Location $scriptDir
try {
& $buildScript -Deployment LocalDev
& $buildScript -Deployment LocalDev -MsBuildVersion $MsBuildVersion
if ($LASTEXITCODE -ne 0) {
Write-Err "Build-VSIX-Local.ps1 exited with code $LASTEXITCODE"
exit $LASTEXITCODE
Expand Down
Loading