Skip to content

Commit 3e8d499

Browse files
vnbaaijdvoituron
andauthored
[dev-v5][Chore] Update publish local (#4665)
* - Enable using net10 for demo - Update publish script * Process review comments * - Undo BuildConstants change * Update publish script. * Update publish script * Skip generating MCP documentation (as it is commented out on dev-v5 as well) * Revert change to TargetFrameworks * Revert update made by publish script * Revert server.json change --------- Co-authored-by: Denis Voituron <dvoituron@outlook.com>
1 parent 72881b2 commit 3e8d499

4 files changed

Lines changed: 149 additions & 39 deletions

File tree

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<PropertyGroup>
33

44
<!-- .NET Framework Version used with the Demo and Unit Tests projects -->
5-
<!-- Change this to switch between net8.0, net9.0, or net10.0 -->
6-
<!--
5+
<!-- Change this to switch between net8.0, net9.0, or net10.0 -->
6+
<!--
77
NOTES: When updating the NetVersion above, also update the files
88
- _PublishDemoLocally.ps1
99
- .github\workflows\build-core-lib.yml

_PublishDemoLocally.ps1

Lines changed: 124 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,54 @@
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
1659
Write-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
3780
Write-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
60140
Write-Host "👉 Publishing demo..." -ForegroundColor Yellow
61141
dotnet 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

67148
if (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
86166
Write-Host "👉 Creating deployment archive..." -ForegroundColor Yellow
87167
if (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 ""
95182
Write-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
98192
Write-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]"
100194
if ($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

examples/Demo/FluentUI.Demo/Components/App.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1616
<base href="/" />
1717
<link rel="stylesheet" href="app.css" />
18-
<link rel="stylesheet" href="FluentUI.Demo.styles.css" />
18+
<link rel="stylesheet" href="@Assets["FluentUI.Demo.styles.css"]" />
1919
<link rel="icon" type="image/x-icon" href="favicon.ico" />
2020
<HeadOutlet @rendermode="@DemoRenderMode" />
2121

2222
<style>
23-
/* Set the default dark mode styles,
23+
/* Set the default dark mode styles,
2424
used before the Fluent UI theme switcher is initialized
2525
This is to avoid a flash of white when in dark mode.
2626
Update as needed to match your dark theme.
@@ -37,7 +37,7 @@
3737
<body use-reboot="@reboot">
3838
<Routes @rendermode="@DemoRenderMode" />
3939
<script src="_framework/blazor.web.js"></script>
40-
40+
4141
<!-- Include highlight.js -->
4242
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/styles/vs.min.css" title="highlight-light" />
4343
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/styles/vs2015.min.css" title="highlight-dark" disabled="disabled" />
@@ -50,7 +50,7 @@
5050
document.body.addEventListener('themeChanged', function (e) {
5151
const linkLight = document.querySelector('link[title="highlight-light"]');
5252
const linkDark = document.querySelector('link[title="highlight-dark"]');
53-
53+
5454
if (linkLight && linkDark) {
5555
linkLight.disabled = e.detail.isDark;
5656
linkDark.disabled = !e.detail.isDark;

src/Core/Microsoft.FluentUI.AspNetCore.Components.csproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@
138138

139139
</Target>
140140

141+
<!-- Temporary fix for problem with .esproj files when using latest SDKs. Will be fully fixed in later SDK -->
142+
<Target Name="FixEsprojOriginalItemSpec"
143+
AfterTargets="ResolveReferencedProjectsStaticWebAssets"
144+
Condition="'@(StaticWebAsset)' != ''">
145+
<ItemGroup>
146+
<_EsprojAssetsToFix Include="@(StaticWebAsset)"
147+
Condition="'%(StaticWebAsset.OriginalItemSpec)' != '' AND $([System.String]::Copy('%(StaticWebAsset.OriginalItemSpec)').EndsWith('.esproj'))" />
148+
</ItemGroup>
149+
<ItemGroup Condition="'@(_EsprojAssetsToFix)' != ''">
150+
<StaticWebAsset Remove="@(_EsprojAssetsToFix)" />
151+
<StaticWebAsset Include="@(_EsprojAssetsToFix)">
152+
<OriginalItemSpec>%(Identity)</OriginalItemSpec>
153+
</StaticWebAsset>
154+
</ItemGroup>
155+
<ItemGroup>
156+
<_EsprojAssetsToFix Remove="@(_EsprojAssetsToFix)" />
157+
</ItemGroup>
158+
</Target>
159+
141160
<!-- Resources Localization -->
142161
<ItemGroup>
143162
<PackageReference Include="Microsoft.CodeAnalysis.ResxSourceGenerator">

0 commit comments

Comments
 (0)