66
77# Script to generate documentation and publish the FluentUI Demo locally
88
9- # .NET Framework Version - Change this to net8.0, net9.0, or net10.0 as needed
10- $NetVersion = " net10.0"
9+ # Ask user for configuration
10+ Write-Host " 👉 Configuration setup..." - ForegroundColor Cyan
11+ Write-Host " "
12+
13+ # Ask for .NET version
14+ $dotnetVersionChoice = Read-Host " ❓ Which .NET version do you want to use? (9 for net9.0, 10 for net10.0) [default: 10]"
15+ if ($dotnetVersionChoice -eq " 9" ) {
16+ $NetVersion = " net9.0"
17+ } elseif ($dotnetVersionChoice -eq " " -or $dotnetVersionChoice -eq " 10" ) {
18+ $NetVersion = " net10.0"
19+ } else {
20+ Write-Host " ⛔ Invalid choice." - ForegroundColor Red
21+ exit 1
22+ }
23+
24+ # Show build number
25+ $path = " ./Directory.Build.props"
26+ $propsContent = Get-Content $path - Raw
1127
12- Write-Host " 👉 Starting local demo publish process..." - ForegroundColor Green
13- Write-Host " 👉 Using .NET Framework: $NetVersion " - ForegroundColor Cyan
28+ $versionPrefix = $propsContent -match " <VersionPrefix>([0-9]+\.[0-9]+\.[0-9]+)</VersionPrefix>"
29+ $pipelineVersion = $Matches [1 ]
30+
31+ $versionSuffix = $propsContent -match " <VersionSuffix>([0-9A-Za-z\.-]+)</VersionSuffix>"
32+ if ($versionSuffix ) {
33+ $pipelineSuffix = $Matches [1 ]
34+ }
35+ if ($pipelineSuffix ) {
36+ $version = " $pipelineVersion -$pipelineSuffix "
37+ } else {
38+ $version = $pipelineVersion
39+ }
40+
41+ Write-Host " "
42+ Write-Host " Configuration:" - ForegroundColor Green
43+ Write-Host " .NET Version: $NetVersion " - ForegroundColor White
44+ Write-Host " Package version: $version " - ForegroundColor White
45+ Write-Host " "
46+
47+ # Ask for doing quick of full publish
48+ $publishChoice = Read-Host " ❓ Do you want to do a full publish (skip API documentation generation, MCP Server build)? (y/n) [default: y]"
49+ if ($publishChoice -eq " n" ) {
50+ $fullBuild = $false
51+ } elseif ($publishChoice -eq " " -or $publishChoice -eq " y" ) {
52+ $fullBuild = $true
53+ } else {
54+ Write-Host " ⛔ Invalid choice." - ForegroundColor Red
55+ exit 1
56+ }
1457
1558# Clean previous build artifacts
1659Write-Host " 👉 Cleaning previous build artifacts (bin and obj)..." - ForegroundColor Yellow
@@ -35,53 +78,90 @@ $RootDir = $PSScriptRoot
3578
3679# Update the Directory.Build.props file with the correct .NET version
3780Write-Host " 👉 Updating Directory.Build.props with .NET version: $NetVersion ..." - ForegroundColor Yellow
38- (Get-Content " ./Directory.Build.props" ) -replace ' <NetVersion>net[0-9]+\.[0-9]+</NetVersion>' , " <NetVersion>$NetVersion </NetVersion>" | Set-Content " ./Directory.Build.props"
39- (Get-Content " ./Directory.Build.props" ) -replace " <TargetNetVersions Condition=`" '\$\(Configuration\)' == 'Release'`" >.*</TargetNetVersions>" , " <TargetNetVersions Condition=`" '`$ (Configuration)' == 'Release'`" >$NetVersion </TargetNetVersions>" | Set-Content " ./Directory.Build.props"
4081
82+ $conditionValue = ' '' $(Configuration)'' == '' Release'' '
83+ $resolvedPath = (Resolve-Path $path ).Path
4184
42- # Build the core project
43- Write-Host " 👉 Building Core project... " - ForegroundColor Yellow
44- dotnet build " ./src/Core/Microsoft.FluentUI.AspNetCore.Components.csproj " - c Release - o " ./src/Core/bin/Publish " -f $NetVersion
85+ # Create a backup of the original Directory.Build.props
86+ $backupPath = " $path .bak "
87+ Copy-Item $path $backupPath - Force
4588
46- # Generate API documentation file
47- Write-Host " 👉 Generating API documentation... " - ForegroundColor Yellow
48- dotnet run -- project " .\examples\Tools\FluentUI.Demo.DocApiGen\FluentUI.Demo.DocApiGen.csproj " -- xml " $RootDir /src/Core/bin/Publish/Microsoft.FluentUI.AspNetCore.Components. xml" -- dll " $RootDir /src/Core/bin/Publish/Microsoft.FluentUI.AspNetCore.Components.dll " -- output " $RootDir /examples/Demo/FluentUI.Demo.Client/wwwroot/api-comments.json " -- format json
89+ $xml = New-Object System.Xml.XmlDocument
90+ $xml .PreserveWhitespace = $true
91+ $ xml.Load ( $resolvedPath )
4992
50- # Build the MCP Server project
51- Write-Host " 👉 Building MCP Server project..." - ForegroundColor Yellow
52- dotnet build " ./src/Tools/McpServer/Microsoft.FluentUI.AspNetCore.McpServer.csproj" - c Release - o " ./src/Tools/McpServer/bin/Publish" -f $NetVersion
93+ # Process NetVersion
94+ $node = $xml.SelectSingleNode (" //NetVersion" )
95+ if ($null -eq $node ) {
96+ throw " Matching NetVersion element not found."
97+ }
98+ if ($node.InnerText -ne $NetVersion ) {
99+ $node.InnerText = $NetVersion
100+ Write-Host " Updated NetVersion temporarily." - ForegroundColor Cyan
101+ $xml.Save ($resolvedPath )
102+ }
53103
54- # Generate MCP documentation file
55- Write-Host " 👉 Generating MCP documentation..." - ForegroundColor Yellow
56- # dotnet run --project ".\examples\Tools\FluentUI.Demo.DocApiGen\FluentUI.Demo.DocApiGen.csproj" --xml "$RootDir/src/Tools/McpServer/bin/Publish/Microsoft.FluentUI.AspNetCore.McpServer.xml" --dll "$RootDir/src/Tools/McpServer/bin/Publish/Microsoft.FluentUI.AspNetCore.McpServer.dll" --output "$RootDir/examples/Demo/FluentUI.Demo.Client/wwwroot/mcp-documentation.json" --format json --mode mcp
57- Write-Host " Skipped."
104+ # Process TargetNetVersions
105+ $nodes = $xml.SelectNodes (" //TargetNetVersions" )
106+ $node = $nodes |
107+ Where-Object { $_.GetAttribute (" Condition" ) -eq $conditionValue } |
108+ Select-Object - First 1
109+
110+ if ($null -eq $node ) {
111+ throw " Matching TargetNetVersions element not found."
112+ }
113+
114+ if ($node.InnerText -ne $NetVersion ) {
115+ $node.InnerText = $NetVersion
116+ Write-Host " Updated TargetNetVersions temporarily." - ForegroundColor Cyan
117+ $xml.Save ($resolvedPath )
118+ }
119+
120+ if ($fullBuild ) {
121+ # Build the core project
122+ Write-Host " 👉 Building Core project..." - ForegroundColor Yellow
123+ dotnet build " ./src/Core/Microsoft.FluentUI.AspNetCore.Components.csproj" - c Release - o " ./src/Core/bin/Publish" -f $NetVersion
124+
125+ # Generate API documentation file
126+ Write-Host " 👉 Generating API documentation..." - ForegroundColor Yellow
127+ dotnet run -- project " .\examples\Tools\FluentUI.Demo.DocApiGen\FluentUI.Demo.DocApiGen.csproj" -- xml " $RootDir /src/Core/bin/Publish/Microsoft.FluentUI.AspNetCore.Components.xml" -- dll " $RootDir /src/Core/bin/Publish/Microsoft.FluentUI.AspNetCore.Components.dll" -- output " $RootDir /examples/Demo/FluentUI.Demo.Client/wwwroot/api-comments.json" -- format json
128+
129+ # Build the MCP Server project
130+ Write-Host " 👉 Building MCP Server project..." - ForegroundColor Yellow
131+ dotnet build " ./src/Tools/McpServer/Microsoft.FluentUI.AspNetCore.McpServer.csproj" - c Release - o " ./src/Tools/McpServer/bin/Publish" -f $NetVersion
132+
133+ # Generate MCP documentation file
134+ Write-Host " 👉 Generating MCP documentation..." - ForegroundColor Yellow
135+ # dotnet run --project ".\examples\Tools\FluentUI.Demo.DocApiGen\FluentUI.Demo.DocApiGen.csproj" --xml "$RootDir/src/Tools/McpServer/bin/Publish/Microsoft.FluentUI.AspNetCore.McpServer.xml" --dll "$RootDir/src/Tools/McpServer/bin/Publish/Microsoft.FluentUI.AspNetCore.McpServer.dll" --output "$RootDir/examples/Demo/FluentUI.Demo.Client/wwwroot/mcp-documentation.json" --format json --mode mcp
136+ Write-Host " Skipped."
137+ }
58138
59139# Publish the demo
60140Write-Host " 👉 Publishing demo..." - ForegroundColor Yellow
61141dotnet publish " ./examples/Demo/FluentUI.Demo/FluentUI.Demo.csproj" - c Release - o " ./examples/Demo/FluentUI.Demo/bin/Publish" -f $NetVersion
62142
63- # Verify that the bundle CSS file has the expected size
64- Write-Host " 👉 Verifying bundle CSS file size..." - ForegroundColor Yellow
65- $bundleFilePath = " ./examples/Demo/FluentUI.Demo/bin/Publish/wwwroot/_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.bundle.scp.css.br"
143+ # Verify that the bundle JS file has the expected size
144+ Write-Host " "
145+ Write-Host " 👉 Verifying bundle JS file size..." - ForegroundColor Yellow
146+ $bundleFilePath = " ./examples/Demo/FluentUI.Demo/bin/Publish/wwwroot/_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js.br"
66147
67148if (Test-Path $bundleFilePath ) {
68149 $fileSize = (Get-Item $bundleFilePath ).Length
69150 $fileSizeKB = [math ]::Round($fileSize / 1024 , 2 )
70151
71152 if ($fileSize -gt 1024 ) {
72- Write-Host " ☑️ Bundle CSS file verified: $fileSizeKB KB" - ForegroundColor Green
153+ Write-Host " ☑️ Bundle JS file verified: $fileSizeKB KB" - ForegroundColor Green
73154 } else {
74- Write-Host " ⛔ Bundle CSS file is too small: $fileSizeKB KB (expected > 1KB)" - ForegroundColor Red
75- Write-Host " ⛔ This may indicate a build issue with the CSS bundle generation." - ForegroundColor Red
76- Write-Host " ⛔ Install .NET 9.0.205 SDK and a `global.json` file with `{ "" sdk"" : { "" version"" : "" 9.0.205"" } }`." - ForegroundColor Red
155+ Write-Host " ⛔ Bundle JS file is too small: $fileSizeKB KB (expected > 1KB)" - ForegroundColor Red
156+ Write-Host " ⛔ This may indicate a build issue with the JS bundle generation." - ForegroundColor Red
157+ Write-Host " ⛔ Install .NET 9.0.205 SDK, remove the references to 'net10' and add a `global.json` file with `{ "" sdk"" : { "" version"" : "" 9.0.205"" } }`." - ForegroundColor Red
77158 exit 1
78159 }
79160} else {
80- Write-Host " ⛔ Bundle CSS file not found: $bundleFilePath " - ForegroundColor Red
81- Write-Host " ⛔ This may indicate a build issue with the CSS bundle generation." - ForegroundColor Red
161+ Write-Host " ⛔ Bundle JS file not found: $bundleFilePath " - ForegroundColor Red
162+ Write-Host " ⛔ This may indicate a build issue with the JS bundle generation." - ForegroundColor Red
82163 exit 1
83164}
84-
85165# Create deployment archive
86166Write-Host " 👉 Creating deployment archive..." - ForegroundColor Yellow
87167if (Test-Path " ./examples/Demo/FluentUI.Demo/bin/Publish" ) {
@@ -92,15 +172,26 @@ if (Test-Path "./examples/Demo/FluentUI.Demo/bin/Publish") {
92172 exit 1
93173}
94174
175+ # Restore previous Directory.Build.props
176+ if (Test-Path $backupPath ) {
177+ Move-Item $backupPath $path - Force
178+ Write-Host " 'Directory.Build.props' restored." - ForegroundColor Cyan
179+ }
180+
181+ Write-Host " "
95182Write-Host " ✅ Demo publish process completed successfully!" - ForegroundColor Green
183+ Write-Host " "
184+
185+ Write-Host " "
186+ Write-Host " ----------------------------------------------------"
187+ Write-Host " 👉 You can deploy to Azure using a command like:" - ForegroundColor Green
188+ Write-Host " ▶️ az webapp deploy --resource-group FluentUI --name fluentui-blazor-v5 --src-path ./examples/Demo/FluentUI.Demo/bin/FluentUI-Blazor.zip --type zip" - ForegroundColor Green
189+ Write-Host " ----------------------------------------------------"
96190
97191# Ask user if they want to run the website
98192Write-Host " "
99- $runWebsite = Read-Host " Do you want to run the website now? (Y /n)"
193+ $runWebsite = Read-Host " Do you want to run the local website now? (y /n) [default: y] "
100194if ($runWebsite -eq " " -or $runWebsite -eq " Y" -or $runWebsite -eq " y" ) {
101195 Write-Host " 👉 Starting the website..." - ForegroundColor Green
102196 Start-Process - FilePath " ./examples/Demo/FluentUI.Demo/bin/Publish/FluentUI.Demo.exe" - WorkingDirectory " ./examples/Demo/FluentUI.Demo/bin/Publish"
103197}
104-
105- Write-Host " 👉 You can deploy to Azure using a command like:" - ForegroundColor Green
106- Write-Host " ▶️ az webapp deploy --resource-group FluentUI --name fluentui-blazor-v5 --src-path ./examples/Demo/FluentUI.Demo/bin/FluentUI-Blazor.zip --type zip" - ForegroundColor Green
0 commit comments