Skip to content

Commit a14c225

Browse files
authored
[net10.0] Merge main net10 (#29273)
### Description of Change Bring latest changes from main to net10.0 branch.
2 parents a73b0fb + 64cf166 commit a14c225

File tree

46 files changed

+2410
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2410
-210
lines changed

build.cake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ PowerShell:
2929
//////////////////////////////////////////////////////////////////////
3030
#tool "nuget:?package=nuget.commandline&version=6.6.1"
3131

32+
3233
//////////////////////////////////////////////////////////////////////
3334
// ARGUMENTS
3435
//////////////////////////////////////////////////////////////////////

docs/CgManifest.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Component Governance Manifest (cgmanifest.json)
2+
3+
This document explains how to manage, update, and include the `cgmanifest.json` file in the MAUI project.
4+
5+
## What is cgmanifest.json?
6+
7+
The Component Governance Manifest (`cgmanifest.json`) is a file that lists all the third-party components used in the project. It helps with tracking dependencies and their versions for security and compliance purposes.
8+
9+
## Automatic Generation
10+
11+
The project includes scripts to automatically generate and update the `cgmanifest.json` file with package versions from the `Versions.props` file.
12+
13+
### Using Cake Build Script
14+
15+
Run the `GenerateCgManifest` task:
16+
17+
```bash
18+
dotnet tool resotre
19+
dotnet cake --target=GenerateCgManifest --workloads=global
20+
```
21+
22+
### Using Scripts Directly
23+
24+
You can also run the PowerShell script directly (works on both Windows and macOS/Linux):
25+
26+
```bash
27+
# On all platforms (Windows/macOS/Linux)
28+
pwsh -ExecutionPolicy Bypass -File ./eng/scripts/update-cgmanifest.ps1
29+
```
30+
31+
### MSBuild Integration
32+
33+
The `CgManifest.targets` file provides MSBuild integration.
34+
35+
#### Default Behavior
36+
37+
By default, the cgmanifest.json file is **always generated** during build, but it is **not included** in the NuGet package. This ensures the manifest is always up-to-date without affecting package contents.
38+
39+
#### Manual Generation
40+
41+
You can explicitly generate the manifest file:
42+
43+
```bash
44+
dotnet build -t:GenerateCgManifest
45+
```
46+
47+
#### Disabling Generation
48+
49+
If needed, you can temporarily disable the automatic generation:
50+
51+
```bash
52+
dotnet build -p:UpdateCgManifestBeforeBuild=false
53+
```
54+
55+
## Including CG Manifest in CI Builds
56+
57+
For CI builds where you want to include the cgmanifest.json in the package:
58+
59+
```bash
60+
dotnet build -p:GenerateCgManifest=true
61+
```
62+
OR
63+
```bash
64+
dotnet pack -p:GenerateCgManifest=true
65+
```
66+
67+
This will:
68+
1. Generate the cgmanifest.json file (happens by default)
69+
2. Include it in the package (for Template projects)
70+
71+
### Azure DevOps Pipeline
72+
73+
Add the following step to your YAML pipeline to include the cgmanifest.json file in the package:
74+
75+
```yaml
76+
- task: DotNetCoreCLI@2
77+
displayName: 'Pack with CG Manifest'
78+
inputs:
79+
command: 'pack'
80+
packagesToPack: 'src/Templates/src/Microsoft.Maui.Templates.csproj'
81+
packDirectory: '$(Build.ArtifactStagingDirectory)/nuget'
82+
arguments: '-p:GenerateCgManifest=true'
83+
```
84+
85+
### GitHub Actions
86+
87+
For GitHub Actions workflows, add this step:
88+
89+
```yaml
90+
- name: Pack with CG Manifest
91+
run: dotnet pack src/Templates/src/Microsoft.Maui.Templates.csproj -p:GenerateCgManifest=true -o $GITHUB_WORKSPACE/artifacts/nuget
92+
```
93+
94+
## Customizing Package Mappings
95+
96+
To add or modify package mappings, edit the PowerShell script: `eng/scripts/update-cgmanifest.ps1` (look for `$packageVersionMappings` hashtable).
97+
98+
## Special Handling for Multiple Versions
99+
100+
The script has special handling for packages that need multiple versions to be included in the manifest:
101+
102+
- **CommunityToolkit.Maui**: Both the current version (`CommunityToolkitMauiPackageVersion`) and previous version (`CommunityToolkitMauiPreviousPackageVersion`) from `Versions.props` are included.
103+
104+
To add similar handling for other packages, modify the script to add special case handling like that implemented for CommunityToolkit.Maui.
105+
106+
## Manual Updates
107+
108+
If you need to manually add packages that aren't in `Versions.props`, you can edit the `cgmanifest.json` file directly. The update scripts preserve manually added entries and only update versions for packages it knows about.
109+
110+
## Verifying the Package
111+
112+
To verify that the cgmanifest.json file is included in the package:
113+
114+
```bash
115+
# On macOS/Linux
116+
find ./artifacts/packages -name "Microsoft.Maui.Templates*.nupkg" | xargs -I{} unzip -l {} | grep cgmanifest.json
117+
118+
# On Windows
119+
foreach ($pkg in (Get-ChildItem -Path ./artifacts/packages -Filter "Microsoft.Maui.Templates*.nupkg")) {
120+
Add-Type -AssemblyName System.IO.Compression.FileSystem
121+
$zip = [System.IO.Compression.ZipFile]::OpenRead($pkg.FullName)
122+
$zip.Entries | Where-Object { $_.Name -eq "cgmanifest.json" -or $_.FullName -like "*cgmanifest.json" }
123+
$zip.Dispose()
124+
}
125+
```

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The table below outlines the different docs in this folder and what they are hel
1010

1111
| Documentation | What is it about? | Who is it for? |
1212
|----------------------|---------------------|---------------------|
13+
| [CG Manifest](CgManifest.md) | Guide to Component Governance manifest generation and management | Contributors who need to manage third-party dependencies or include CG manifest in packages |
1314
| [Code Documentation Guidelines](CodeDocumentationGuidelines.md) | Overview of the guidelines for the inline code documentation | Community members and collaborators looking to understand how to add good inline code comments that fuel our IntelliSense and online API docs |
1415
| [Issue management](IssueManagementPolicies.md) | Overview of policies in place to manage issues| Community members and collaborators looking to understand how we handle closed issues, issues that need author feedback, etc. |
1516
| [Release Schedule](ReleaseSchedule.md) | Overview of .NET MAUI version releases | Anyone who is interested in .NET MAUI versions and release dates |

eng/CgManifest.targets

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
<!--
4+
This file contains targets for generating and updating the cgmanifest.json file with versions from Versions.props.
5+
Include this file in your project to ensure component governance manifests are kept up to date.
6+
7+
Usage:
8+
- For CI: dotnet build -p:GenerateCgManifest=true
9+
- Manual: dotnet build -t:GenerateCgManifest
10+
-->
11+
12+
<PropertyGroup>
13+
<CgManifestPath>$(MSBuildThisFileDirectory)..\..\src\Templates\src\cgmanifest.json</CgManifestPath>
14+
<!-- Always generate cgmanifest.json file by default during build -->
15+
<UpdateCgManifestBeforeBuild Condition="'$(UpdateCgManifestBeforeBuild)' == ''">true</UpdateCgManifestBeforeBuild>
16+
<!-- Detect if we're in CI build -->
17+
<IsInCIBuild Condition="'$(TF_BUILD)' == 'true' OR '$(GITHUB_ACTIONS)' == 'true'">true</IsInCIBuild>
18+
<IsInCIBuild Condition="'$(IsInCIBuild)' == ''">false</IsInCIBuild>
19+
<!-- Global switch to control whether to include cgmanifest.json in package (defaults to false) -->
20+
<GenerateCgManifest Condition="'$(GenerateCgManifest)' == ''">false</GenerateCgManifest>
21+
</PropertyGroup>
22+
23+
<!-- Always update cgmanifest.json before build -->
24+
<Target Name="UpdateCgManifest" BeforeTargets="BeforeBuild" Condition="'$(UpdateCgManifestBeforeBuild)' == 'true'">
25+
<Message Text="Updating cgmanifest.json from Versions.props" Importance="high" />
26+
<Exec Command="pwsh -NonInteractive -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)scripts\update-cgmanifest.ps1&quot;" />
27+
</Target>
28+
29+
<!-- Add a custom target to update cgmanifest.json on demand -->
30+
<Target Name="GenerateCgManifest">
31+
<Message Text="Generating cgmanifest.json from Versions.props" Importance="high" />
32+
<Exec Command="pwsh -NonInteractive -ExecutionPolicy Bypass -File &quot;$(MSBuildThisFileDirectory)scripts\update-cgmanifest.ps1&quot;" />
33+
</Target>
34+
</Project>

eng/Versions.props

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<!-- wasdk -->
6565
<MicrosoftWindowsAppSDKPackageVersion>1.7.250401001</MicrosoftWindowsAppSDKPackageVersion>
6666
<MicrosoftWindowsSDKBuildToolsPackageVersion>10.0.22621.756</MicrosoftWindowsSDKBuildToolsPackageVersion>
67-
<MicrosoftGraphicsWin2DPackageVersion>1.2.0</MicrosoftGraphicsWin2DPackageVersion>
67+
<MicrosoftGraphicsWin2DPackageVersion>1.3.2</MicrosoftGraphicsWin2DPackageVersion>
6868
<MicrosoftWindowsWebView2PackageVersion>1.0.2903.40</MicrosoftWindowsWebView2PackageVersion>
6969
<!-- Everything else -->
7070
<MicrosoftAspNetCoreAuthorizationPackageVersion>10.0.0-preview.4.25230.109</MicrosoftAspNetCoreAuthorizationPackageVersion>
@@ -153,6 +153,13 @@
153153
<XunitAbstractionsPackageVersion>2.0.3</XunitAbstractionsPackageVersion>
154154
<NSubstitutePackageVersion>5.1.0</NSubstitutePackageVersion>
155155
<CoverletCollectorPackageVersion>6.0.0</CoverletCollectorPackageVersion>
156+
<!-- Additional packages for cgmanifest.json -->
157+
<SyncfusionMauiToolkitPackageVersion>1.0.4</SyncfusionMauiToolkitPackageVersion>
158+
<MicrosoftDataSqliteCorePackageVersion>8.0.8</MicrosoftDataSqliteCorePackageVersion>
159+
<SQLitePCLRawBundleGreenPackageVersion>2.1.10</SQLitePCLRawBundleGreenPackageVersion>
160+
<CommunityToolkitMauiPackageVersion>11.1.1</CommunityToolkitMauiPackageVersion>
161+
<CommunityToolkitMauiPreviousPackageVersion>9.1.0</CommunityToolkitMauiPreviousPackageVersion>
162+
<CommunityToolkitMvvmPackageVersion>8.3.2</CommunityToolkitMvvmPackageVersion>
156163
</PropertyGroup>
157164
<PropertyGroup>
158165
<!-- Appium -->

eng/automation/cspell/cSpell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"netstandard",
1010
"Appium",
1111
"XCUI",
12-
"Automator"
12+
"Automator",
13+
"cgmanifest"
1314
],
1415
"ignoreWords": [],
1516
"patterns": [

eng/cake/dotnet.cake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,48 @@ Task("VS")
510510
});
511511

512512

513+
Task("GenerateCgManifest")
514+
.Description("Generates the cgmanifest.json file with versions from Versions.props")
515+
.Does(() =>
516+
{
517+
Information("Generating cgmanifest.json from Versions.props");
518+
519+
// Use pwsh on all platforms
520+
var pwshExecutable = "pwsh";
521+
522+
// Check if pwsh is available
523+
try {
524+
if (IsRunningOnWindows()) {
525+
var exitCode = StartProcess("where", new ProcessSettings {
526+
Arguments = "pwsh",
527+
RedirectStandardOutput = true,
528+
RedirectStandardError = true
529+
});
530+
if (exitCode != 0) {
531+
Information("pwsh not found, falling back to powershell");
532+
pwshExecutable = "powershell";
533+
}
534+
} else {
535+
var exitCode = StartProcess("which", new ProcessSettings {
536+
Arguments = "pwsh",
537+
RedirectStandardOutput = true,
538+
RedirectStandardError = true
539+
});
540+
if (exitCode != 0) {
541+
throw new Exception("PowerShell Core (pwsh) is not installed. Please install it to continue.");
542+
}
543+
}
544+
} catch (Exception ex) when (!IsRunningOnWindows()) {
545+
Error("Error checking for pwsh: " + ex.Message);
546+
throw new Exception("PowerShell Core (pwsh) is required on non-Windows platforms. Please install it and try again.");
547+
}
548+
549+
// Execute the PowerShell script
550+
StartProcess(pwshExecutable, new ProcessSettings {
551+
Arguments = "-NonInteractive -ExecutionPolicy Bypass -File ./eng/scripts/update-cgmanifest.ps1"
552+
});
553+
});
554+
513555
bool RunPackTarget()
514556
{
515557
// Is the user running the pack target explicitly?

0 commit comments

Comments
 (0)