-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet build fails when WindowsAppSDK is referenced in console application. #3548
Comments
Yeah, this is weird. From what I can tell while examining the targets files, the modern ( |
I set following property in the winui project and it compiles now in visual studio and on the dotnet build command line. |
Just found out that adding the property as provided by @inforithmics to the other project solves the issue in my end. Thank you! |
I can confirm that it works on my projects too, thanks for the help! Is this the expected workaround? And if so, could we improve the documentation around this? |
I guess I was too smart for my own good Move GenerateLibraryOutput down to relevant block Add workaround for microsoft/WindowsAppSDK#3548 Does this work? Ok now it will work
* Add properties to easily check Target Platform * Add MacCatalyst plugins I guess I was too smart for my own good Move GenerateLibraryOutput down to relevant block Add workaround for microsoft/WindowsAppSDK#3548 Does this work? Ok now it will work
Had the same issue as in I couldn't build the standalone UI project and added @inforithmics workaround and confirm it works - getting build errors though but at least it's trying to build now!
EDIT: Removed namespace error and added error corresponding to the issue |
This works. |
It is important to note that setting When disabled, |
Thanks for the clarification. Does that matter if the library has no XAML files (i.e WinAppSdk is being used but no XAML)? |
@abdes only if there are XAML files indeed, I've adjusted my comment above. |
I resolved the PRI DLL issue by modifying the targets file like this <AppxMSBuildToolsPath Condition="'$(AppxMSBuildToolsPath)' == ''">C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\</AppxMSBuildToolsPath> For me, the DLL was located in this folder, not from the dotnet folder as indicated by the error. However, I still couldn't get |
<AppxMSBuildToolsPath Condition="'$(AppxMSBuildToolsPath)' == ''">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\AppxPackage\</AppxMSBuildToolsPath>
<PriProjTaskAssembly Condition="'$(PriProjTaskAssembly)' == ''">$(AppxMSBuildToolsPath)\Microsoft.Build.Packaging.Pri.Tasks.dll</PriProjTaskAssembly>
<AppxMSBuildTaskAssembly Condition="'$(AppxMSBuildTaskAssembly)' == ''">$(AppxMSBuildToolsPath)Microsoft.Build.AppxPackage.dll</AppxMSBuildTaskAssembly> AppxMSBuildToolsPath = C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\ PriProjTaskAssembly = C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.Build.Packaging.Pri.Tasks.dll AppxMSBuildTaskAssembly = C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.Build.AppxPackage.dll But the TargetFramework of |
Can we degraded it to .NET Standard, or copy as .NET Core version?
|
It is expected that in order to enable this scenario you need to add the following property to your project file: |
@evelynwu-msft |
Please provide more details and a binlog.
|
@evelynwu-msft The error output:
Build command: My csproj code: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows10.0.19041</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWinUI>true</UseWinUI>
<Platforms>x86;x64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<EnableMsixTooling>true</EnableMsixTooling>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240607001" />
</ItemGroup>
</Project> My program file: // See https://aka.ms/new-console-template for more information
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace BeregemnallchunufeRojergalbu;
internal class Program
{
static void Main(string[] args)
{
global::WinRT.ComWrappersSupport.InitializeComWrappers();
global::Microsoft.UI.Xaml.Application.Start((p) =>
{
var app = new App();
app.Launched += (sender, e) =>
{
var window = new Window()
{
Title = "Create Window from console"
};
window.Content = new Grid()
{
Children =
{
new TextBlock()
{
Text = "ConsoleApplication",
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
}
}
};
window.Activate();
};
});
}
}
public class App : Application
{
public event EventHandler<LaunchActivatedEventArgs>? Launched;
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
Launched?.Invoke(this, args);
}
} You can find my demo code in: https://github.com/lindexi/lindexi_gd/tree/7fb1a1db6e329d55ff803944c7a606c870f2dd34/BeregemnallchunufeRojergalbu The version of dotnet SDK is 8.0.206 |
My VS (17.10) and .NET SDK (8.0.300) are slightly newer than yours but I don't think that matters. |
Describe the bug
Building a blank console application with .NET 6 through dotnet cli
dotnet build
fails with the following error.Note: I tried with both latest and the preview version.
1.2.230313.1
1.3.230228005-preview1
Steps to reproduce the bug
Expected behavior
The build succeeds.
Screenshots
No response
NuGet package version
Windows App SDK 1.2.5: 1.2.230313.1
Packaging type
Unpackaged
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
No response
The text was updated successfully, but these errors were encountered: