Skip to content

Commit

Permalink
Add extension script and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
roxk committed Mar 27, 2024
1 parent 0afb28b commit a0c053f
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 18 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ jobs:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- run: ./WinUI3XamlPreview/scripts/ci
- working-directory: WinUI3XamlPreview
run: ./scripts/ci
build:
runs-on: windows-2022
needs: ["test"]
if: startsWith(github.ref, 'refs/tags')
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: 0.1.0
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
Expand All @@ -29,3 +30,17 @@ jobs:
run: |
./scripts/build -version $env:VERSION
./scripts/publish-nuget -version $env:VERSION
build-extension:
runs-on: windows-2022
needs: ["test"]
if: startsWith(github.ref, 'refs/tags/vs2022-v')
steps:
- uses: actions/checkout@v3
- uses: microsoft/[email protected]
- working-directory: extensions/WinUI3XamlPrevieVS2022
run: ./scripts/build-extension -config Release
- uses: cezarypiatek/[email protected]
with:
extension-file: './extensions/WinUI3XamlPrevieVS2022/WinUI3XamlPrevieVS2022/bin/Release/net480/WinUI3XamlPrevieVS2022.vsix'
publish-manifest-file: './extension/WinUI3XamlPrevieVS2022/vs-publish.json'
personal-access-code: ${{ secrets.VS_MARKETPLACE_API_KEY }}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# WinUI 3 Xaml Preview (WinUI3XP)

[![nuget](https://img.shields.io/nuget/v/WinUI3XamlPreview)](https://www.nuget.org/packages/WinUI3XamlPreview/)
[![VS2022](https://img.shields.io/visual-studio-marketplace/v/Roxk.winui3xamlpreview.svg?label=Visual%20Studio%202022%20(Preview))](https://marketplace.visualstudio.com/items?itemName=Roxk.winui3xamlpreview)
[![CI](https://github.com/roxk/WinUI3XamlPreview/actions/workflows/ci.yaml/badge.svg)](https://github.com/roxk/WinUI3XamlPreview/actions/workflows/ci.yaml)

![Image showcasing how to use WinUI 3 Xaml Preview](hero-banner.gif)

WinUI3 Xaml Preview allows you to see a a live preview of your UI while authoring XAML. It is fast, reliable, and comes with basic tools like scaling and size configuration.

Featurs:
## Features:
- Interactive preview of your XAML code (powered by `XamlReader`)
- Integration with VS2022 17.9+
- Reload via opening/saving/switching
- Supports your own user control and custom control
- Supports controls in dependency (i.e. libraries)

Limitation:
## Limitation:
- Require building the project once before use
- Packaged apps require launching once after build, before use
- Require a few lines of setup
Expand Down
2 changes: 1 addition & 1 deletion WinUI3XamlPreview/TestPackaged/BlankPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<StackPanel>
<Button Content="Test" />
<dep:DepCustomControl />
<dep:DepUserControl HorizontalAlignment="Left" />
<dep:DepUserControl />
</StackPanel>
</Page>
8 changes: 4 additions & 4 deletions WinUI3XamlPreview/scripts/build-nuget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ $template = Get-Content $PSScriptRoot\..\Nuget\WinUI3XamlPreview.nuspec.template
$nuspec = $template.Replace("VERSION", $version)
Set-Content -path $PSScriptRoot\..\Nuget\.nuspec -value $nuspec
. "$PSScriptRoot\get-msbuild"
nuget restore $PSScriptRoot\..\WinUI3XamlPreview\WinUI3XamlPreview.vcxproj -PackagesDirectory $PSScriptRoot\..\packages
&$msbuild $PSScriptRoot\.. -t:WinUI3XamlPreview -p:Platform=x64,Configuration=Release
&$msbuild $PSScriptRoot\.. -t:WinUI3XamlPreviewCs -p:Platform=x64,Configuration=Release
nuget restore $PSScriptRoot\..\WinUI3XamlPreview\WinUI3XamlPreview.vcxproj -PackagesDirectory $PSScriptRoot\..\packages | out-host
&$msbuild $PSScriptRoot\.. -t:WinUI3XamlPreview -p:Platform=x64,Configuration=Release | out-host
&$msbuild $PSScriptRoot\.. -t:WinUI3XamlPreviewCs -p:Platform=x64,Configuration=Release | out-host
# TODO: Fix ARM support. idlgen is attempting to use ARM64/idlgen.exe when the host is x64.
#&$msbuild $PSScriptRoot\..\WinUI3XamlPreview\WinUI3XamlPreview.vcxproj -p:Platform=ARM64,Configuration=Release
nuget pack $PSScriptRoot\..\Nuget\.nuspec -outputDirectory $PSScriptRoot\..\Nuget
nuget pack $PSScriptRoot\..\Nuget\.nuspec -outputDirectory $PSScriptRoot\..\Nuget | out-host
2 changes: 1 addition & 1 deletion WinUI3XamlPreview/scripts/format.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ if ($check.IsPresent) {
}
$files = get-childitem -r $PSScriptRoot\.. | where { $_.FullName -notMatch 'Generated Files|x64|ARM64|obj|bin|packages' } | where { $_.FullName -Match '.xaml$' }
foreach ($file in $files) {
dotnet xstyler -r -f $file.FullName $passive
dotnet xstyler -r -f $file.FullName $passive | out-host
}
4 changes: 2 additions & 2 deletions WinUI3XamlPreview/scripts/publish-nuget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ param(
[Parameter(Mandatory=$true)]
[String]$version
)
nuget setApiKey $env:NUGET_API_KEY
nuget push $PSScriptRoot\..\Nuget\WinUI3XamlPreview.$version.nupkg -Source https://api.nuget.org/v3/index.json
nuget setApiKey $env:NUGET_API_KEY | out-host
nuget push $PSScriptRoot\..\Nuget\WinUI3XamlPreview.$version.nupkg -Source https://api.nuget.org/v3/index.json | out-host
2 changes: 1 addition & 1 deletion WinUI3XamlPreview/scripts/setup.ps1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet tool restore
dotnet tool restore | out-host
6 changes: 4 additions & 2 deletions WinUI3XamlPreview/scripts/test.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
. "$PSScriptRoot\get-msbuild"
&$msbuild $PSScriptRoot\..\TestPacakged\TestPackaged.csproj -t:Restore
&$msbuild $PSScriptRoot\.. -t:TestPackaged -p:Platform=x64,Configuration=Debug
&$msbuild $PSScriptRoot\..\TestDep\TestDep.vcxproj -t:Restore | out-host
&$msbuild $PSScriptRoot\..\WinUI3XamlPreview\WinUI3XamlPreview.vcxproj -t:Restore | out-host
&$msbuild $PSScriptRoot\..\TestPackaged\TestPackaged.vcxproj -t:Restore | out-host
&$msbuild $PSScriptRoot\.. -t:TestPackaged -p:Platform=x64,Configuration=Debug | out-host
8 changes: 8 additions & 0 deletions extensions/WinUI3XamlPreviewVS2022/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Welcome to WinUI3 Xaml Preview Extension

## Prerequisite
- [WinUI3XamlPreview](https://www.nuget.org/packages/WinUI3XamlPreview/) nuget on nuget gallery.

## Getting started

Refer to the readme in https://github.com/roxk/WinUI3XamlPreview for more instructions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="WinUI3XamlPreviewVS2022.419c3506-e387-4816-bc98-50b888b96498" Version="1.0" Language="en-US" Publisher="Publisher name" />
<DisplayName>WinUI3XamlPreviewVS2022</DisplayName>
<Description>VisualStudio.Extensibility Extension with VSSDK Compatibility.</Description>
<Identity Id="WinUI3XamlPreviewVS2022.419c3506-e387-4816-bc98-50b888b96498" Version="0.1.0" Language="en-US" Publisher="Roxk Yiu" />
<DisplayName>WinUI3XamlPreview VS2022 Extension</DisplayName>
<Description>This extension allows developers to see a live preview while writing XAML in WinUI 3</Description>
<Tags>WinUI3, WinUI 3, WinUI, XAML, Preview, Live Preview</Tags>
<Preview>true</Preview>
</Metadata>
<Installation ExtensionType="VSSDK+VisualStudio.Extensibility">
Expand Down
14 changes: 14 additions & 0 deletions extensions/WinUI3XamlPreviewVS2022/scripts/build-extension.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
param(
[boolean]$buildClang,
[string]$config
)

if (!($config -eq "Release" -or $config -eq "Debug")) {
echo "Uknown config: $config. -config [Release|Debug]"
exit 1
}

$srcDir = "$PSScriptRoot"
$solutionDir = "$srcDir\.."
msbuild "${solutionDir}WinUI3XamlPreviewVS2022\WinUI3XamlPreviewVS2022.csproj" -restore
msbuild $solutionDir -t:WinUI3XamlPreviewVS2022 -p:Configuration=$config
12 changes: 12 additions & 0 deletions extensions/WinUI3XamlPreviewVS2022/vs-publish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "http://json.schemastore.org/vsix-publish",
"categories": [ "programming languages" ],
"identity": {
"internalName": "winui3xamlpreview",
"tags": [ "WinUI3", "WinUI 3", "WinUI", "XAML", "Preview", "Live Preview" ]
},
"assetFiles": [],
"overview": "README.md",
"publisher": "Roxk",
"repo": "https://github.com/roxk/WinUI3XamlPreview"
}
Binary file added hero-banner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a0c053f

Please sign in to comment.