Open jingliancui opened 2 months ago
The link to SampleApp appears to be missing. Please attach a replacement sample app.
https://github.com/jingliancui/WinuiPublishSampleApp @RDMacLachlan I've add code to a repo, just check it out and try
@jingliancui
for now you can install Microsoft.Windows.CsWinRT
package, after dotnet update, you dont need to install this package.
I would suggest trying this again with the October .NET SDK update installed. That should have the source generator enabled and you won't need to the CsWinRT package reference or the WindowsSdkPackageVersion property.
Hi @ghost1372 After reference the cswinrt and publish, error occurred:
Build started at 20:50...
1>------ Build started: Project: SampleApp, Configuration: Release x64 ------
Restored C:\Users\ericc\Documents\GitHub\WinuiPublishSampleApp\SampleApp\SampleApp\SampleApp.csproj (in 65 ms).
1>0 IID calculations/fetches patched
1>SampleApp -> C:\Users\ericc\Documents\GitHub\WinuiPublishSampleApp\SampleApp\SampleApp\bin\x64\Release\net8.0-windows10.0.19041.0\win-x64\SampleApp.dll
2>------ Publish started: Project: SampleApp, Configuration: Release x64 ------
2>Determining projects to restore...
2>Restored C:\Users\ericc\Documents\GitHub\WinuiPublishSampleApp\SampleApp\SampleApp\SampleApp.csproj (in 149 ms).
2>"C:\Users\ericc\.nuget\packages\microsoft.windows.cswinrt\2.1.6\cswinrt.exe" @"Generated Files\\CsWinRT\cswinrt.rsp"
2>EXEC(0,0): Error : Could not read the Windows SDK's Platform.xml at C:\Program Files (x86)\Windows Kits\10\Platforms\UAP\10.0.19041.0\Platform.xml
2>C:\Users\ericc\.nuget\packages\microsoft.windows.cswinrt\2.1.6\build\Microsoft.Windows.CsWinRT.targets(292,5): Error MSB3073: The command ""C:\Users\ericc\.nuget\packages\microsoft.windows.cswinrt\2.1.6\cswinrt.exe" @"Generated Files\\CsWinRT\cswinrt.rsp"" exited with code 1.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 20:50 and took 24.544 seconds ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
========== Publish completed at 20:50 and took 24.544 seconds ==========
@jingliancui can you upload a repro project? Also visual studio released a new update preview 3 and latest stable 16.4.5 (i think) and there is no need for cswinrt and WindowsSdkPackageVersion. So i suggest you to update visual studio to latest
Hi @ghost1372 I've uploaded the the repo to github early, https://github.com/jingliancui/WinuiPublishSampleApp Just check it out and try, My vs version is:
Microsoft Visual Studio Community 2022
Version 17.11.5
VisualStudio.17.Release/17.11.5+35327.3
Microsoft .NET Framework
Version 4.8.09032
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA876
Microsoft Visual C++ 2022
ASP.NET and Web Tools 17.11.231.19466
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.11.231.19466
Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 17.11.231.19466
Azure Functions and Web Jobs Tools
C# Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Dotfuscator Community Edition 6.5.3+7f0b0a9d18
PreEmptive Protection - Dotfuscator CE
Extensibility Message Bus 1.4.39 (main@e8108eb)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
GitHub Copilot 0.2.1657.32929
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Mono Debugging for Visual Studio 17.11.3 (ba13144)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 6.11.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.11.3.2442001+68650a7d94261bc56a1f4bc522c2ee35314b1abb
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.11.47.0
Microsoft SQL Server Data Tools
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
TypeScript Tools 17.0.30715.2002
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.11.0-beta.24421.7+af2f522de602281d4ef5a7b71507c428e814c5c1
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
VSPackage Extension 1.0
VSPackage Visual Studio Extension Detailed Info
Xamarin 17.11.0.98 (d17-11@86652fe)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 17.11.3.11 (remotes/origin/d17-11@cdbb0a4fdd)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: d9a6e87
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite/3.40.1@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d
That's my env:
Usage: dotnet [options]
Usage: dotnet [path-to-application]
Options:
-h|--help Display help.
--info Display .NET information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.
path-to-application:
The path to an application .dll file to execute.
C:\Users\ericc>dotnet --info
.NET SDK:
Version: 8.0.403
Commit: c64aa40a71
Workload version: 8.0.400-manifests.e99c892e
MSBuild version: 17.11.9+a69bbaaf5
运行时环境:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.403\
已安装 .NET 工作负载:
配置为在安装新清单时使用 loose manifests。
[maccatalyst]
安装源文件: VS 17.11.35327.3
清单版本: 18.0.8303/8.0.100
清单路径: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\18.0.8303\WorkloadManifest.json
安装类型: FileBased
[android]
安装源文件: VS 17.11.35327.3
清单版本: 34.0.113/8.0.100
清单路径: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.113\WorkloadManifest.json
安装类型: FileBased
[ios]
安装源文件: VS 17.11.35327.3
清单版本: 18.0.8303/8.0.100
清单路径: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\18.0.8303\WorkloadManifest.json
安装类型: FileBased
[aspire]
安装源文件: VS 17.11.35327.3
清单版本: 8.1.0/8.0.100
清单路径: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json
安装类型: FileBased
[maui-windows]
安装源文件: VS 17.11.35327.3
清单版本: 8.0.82/8.0.100
清单路径: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.82\WorkloadManifest.json
安装类型: FileBased
Host:
Version: 8.0.10
Architecture: x64
Commit: 81cabf2857
.NET SDKs installed:
7.0.311 [C:\Program Files\dotnet\sdk]
8.0.403 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
after I remove the WindowsSdkPackageVersion, it can be build, but it still can not run.
after I remove the WindowsSdkPackageVersion, it can be build, but it still can not run.
i dont have any issue! Please remove bin/obj and try again.
@ghost1372 could you view this video please? https://github.com/user-attachments/assets/a240cff8-7939-432d-b644-30849d7139e2
@ghost1372 And I wonder, why your config is debug and x64? and using f5? You should try publish.
@ghost1372 And I wonder, why your config is debug and x64? and using f5? You should try publish.
You can not Directly execute exe file, while you are using Packaged App! you need to define UnPackaged App first:
<WindowsPackageType>None</WindowsPackageType>
@jingliancui
I also suggest using the following setting for now to have less problems with trim (default option with .Net >= 8 is full)
<TrimMode>partial</TrimMode>
Thanks @ghost1372 after add the config, and show below error when try to run
<TrimMode>partial</TrimMode>
<WindowsPackageType>None</WindowsPackageType>
Thanks @ghost1372 after add the config, and show below error when try to run
<TrimMode>partial</TrimMode> <WindowsPackageType>None</WindowsPackageType>
Try set this option:
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
If you get error again, download and install wasdk runtime from here
https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads
Finally it could work! @ghost1372 thank you so much! Then I think this issue can be mark as done.
But do I need to open 2 new issue? One is supplement docs details about add below config:
<TrimMode>partial</TrimMode>
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
One is the VS UI publish config not work even I select SelfContained, it should config in the csproj by:
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
Finally it could work! @ghost1372 thank you so much! Then I think this issue can be mark as done.
But do I need to open 2 new issue? One is supplement docs details about add below config:
<TrimMode>partial</TrimMode> <WindowsPackageType>None</WindowsPackageType> <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
One is the VS UI publish config not work even I select SelfContained, it should config in the csproj by:
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
All of them are documented, you can find them in multiple sections
https://learn.microsoft.com/en-us/windows/apps/package-and-deploy/project-properties
Note that WindowsAppSDKSelfContained
is different from SelfContained
WindowsAppSDKSelfContained only control wasdk runtime, while SelfContained control dotnet runtime and all other dependencies.
So if you need a full self-contained, then make sure both are set to true
Describe the bug
https://github.com/jingliancui/WinuiPublishSampleApp
Steps to reproduce the bug
Expected behavior
the mainpage shows
Screenshots
no page shows
NuGet package version
Windows App SDK 1.6.1: 1.6.240923002
Packaging type
Unpackaged
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
No response