diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index 80ec52d9d4..34ac24ae41 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -344,6 +344,11 @@ jobs: flattenFolders: True OverWrite: True + # Check if all projects (located in src sub-folder) import common props + - pwsh: |- + & '.pipelines/verifyCommonProps.ps1' -sourceDir '$(build.sourcesdirectory)\src' + displayName: Audit shared common props for CSharp projects in src sub-folder + # Check if deps.json files don't reference different dll versions. - pwsh: |- & '.pipelines/verifyDepsJsonLibraryVersions.ps1' -targetDir '$(build.sourcesdirectory)\$(BuildPlatform)\$(BuildConfiguration)' diff --git a/.pipelines/verifyCommonProps.ps1 b/.pipelines/verifyCommonProps.ps1 new file mode 100644 index 0000000000..028578234c --- /dev/null +++ b/.pipelines/verifyCommonProps.ps1 @@ -0,0 +1,54 @@ +[CmdletBinding()] +Param( + [Parameter(Mandatory = $True, Position = 1)] + [string]$sourceDir +) + +# scan all csharp project in the source directory +function Get-CSharpProjects { + param ( + [string]$path + ) + + # Get all .csproj files under the specified path + return Get-ChildItem -Path $path -Recurse -Filter *.csproj | Select-Object -ExpandProperty FullName +} + +# Check if the project file imports 'Common.Dotnet.CsWinRT.props' +function Test-ImportSharedCsWinRTProps { + param ( + [string]$filePath + ) + + # Load the XML content of the .csproj file + [xml]$csprojContent = Get-Content -Path $filePath + + + # Check if the Import element with Project attribute containing 'Common.Dotnet.CsWinRT.props' exists + return $csprojContent.Project.Import | Where-Object { $null -ne $_.Project -and $_.Project.EndsWith('Common.Dotnet.CsWinRT.props') } +} + +# Call the function with the provided source directory +$csprojFilesArray = Get-CSharpProjects -path $sourceDir + +$hasInvalidCsProj = $false + +# Enumerate the array of file paths and call Validate-ImportSharedCsWinRTProps for each file +foreach ($csprojFile in $csprojFilesArray) { + # Skip if the file ends with 'TemplateCmdPalExtension.csproj' + if ($csprojFile -like '*TemplateCmdPalExtension.csproj') { + continue + } + + $importExists = Test-ImportSharedCsWinRTProps -filePath $csprojFile + if (!$importExists) { + Write-Output "$csprojFile need to import 'Common.Dotnet.CsWinRT.props'." + $hasInvalidCsProj = $true + } +} + +if ($hasInvalidCsProj) { + exit 1 +} + +exit 0 \ No newline at end of file diff --git a/src/Common.Dotnet.FuzzTest.props b/src/Common.Dotnet.FuzzTest.props new file mode 100644 index 0000000000..d0749d516a --- /dev/null +++ b/src/Common.Dotnet.FuzzTest.props @@ -0,0 +1,10 @@ + + + + + + net8.0-windows10.0.19041.0 + + diff --git a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj index f22ee39381..2d0b5f1ad1 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj +++ b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj @@ -1,6 +1,8 @@ + + + - net8.0-windows10.0.19041.0 latest enable enable diff --git a/src/modules/Hosts/Hosts.FuzzTests/Hosts.FuzzTests.csproj b/src/modules/Hosts/Hosts.FuzzTests/Hosts.FuzzTests.csproj index 714b9ec3ac..8c0f107395 100644 --- a/src/modules/Hosts/Hosts.FuzzTests/Hosts.FuzzTests.csproj +++ b/src/modules/Hosts/Hosts.FuzzTests/Hosts.FuzzTests.csproj @@ -1,6 +1,9 @@  + + + + - net8.0-windows10.0.19041.0 latest enable diff --git a/src/modules/registrypreview/RegistryPreview.FuzzTests/RegistryPreview.FuzzTests.csproj b/src/modules/registrypreview/RegistryPreview.FuzzTests/RegistryPreview.FuzzTests.csproj index d59656463e..c4d6fa1cd2 100644 --- a/src/modules/registrypreview/RegistryPreview.FuzzTests/RegistryPreview.FuzzTests.csproj +++ b/src/modules/registrypreview/RegistryPreview.FuzzTests/RegistryPreview.FuzzTests.csproj @@ -1,9 +1,11 @@ + + + - net8.0-windows10.0.19041.0 - x64;ARM64 - latest + x64;ARM64 + latest enable enable