Skip to content
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

Unable to build Windows class libraries with dotnet build #5886

Closed
mattleibow opened this issue Apr 7, 2022 · 6 comments · Fixed by #6068
Closed

Unable to build Windows class libraries with dotnet build #5886

mattleibow opened this issue Apr 7, 2022 · 6 comments · Fixed by #6068
Labels
fixed-in-6.0.300-rc.2 Look for this fix in 6.0.300-rc.2! legacy-area-desktop Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) platform/windows 🪟 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK)
Milestone

Comments

@mattleibow
Copy link
Member

mattleibow commented Apr 7, 2022

Description

We added support for dotnet build, but it seems that libraries still have some issues.

Partial PR: #5875
Maui devops issue: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1520610
OS devops issue: https://microsoft.visualstudio.com/OS/_workitems/edit/38897015

Steps to Reproduce

  1. Create a new winui class library
  2. dotnet build
  3. Observe the error saying it can't load the Pri tasks
D:\a\_work\_temp\templatesTest\packages\microsoft.windowsappsdk\1.0.2\buildTransitive\MrtCore.PriGen.targets(891,5):
    error MSB4062: The "Microsoft.Build.Packaging.Pri.Tasks.ExpandPriContent" task could not be loaded from the 
    assembly D:\a\_work\1\s\bin\dotnet\sdk\6.0.300-preview.22204.3\\Microsoft\VisualStudio\v17.0\AppxPackage\\Microsoft.Build.Packaging.Pri.Tasks.dll. 
    Could not load file or assembly 'D:\a\_work\1\s\bin\dotnet\sdk\6.0.300-preview.22204.3\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.Build.Packaging.Pri.Tasks.dll'. 
    The system cannot find the path specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are
    available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
    [D:\a\_work\_temp\templatesTestmauilibTrue\templatesTestmauilibTrue.csproj]

Version with bug

Release Candidate 1

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

All

Did you find any workaround?

Use msbuild :(

Relevant log output

No response

@mattleibow mattleibow added t/bug Something isn't working s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 7, 2022
@mattleibow mattleibow added this to the 6.0.300-rc.2 milestone Apr 7, 2022
@mattleibow mattleibow added platform/windows 🪟 legacy-area-desktop Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 7, 2022
@mattleibow mattleibow reopened this Apr 14, 2022
@mattleibow
Copy link
Member Author

My PR fixes the issue as seen by human eyes, but there are some hidden issues in some areas. Reopening this and will PR more fixes from the WinUI team.

@Juriyx
Copy link

Juriyx commented May 10, 2022

Same stuff on GitHub Actions
C:\Users\runneradmin\.nuget\packages\microsoft.windowsappsdk\1.0.3\buildTransitive\MrtCore.PriGen.targets(891,5): error MSB[40](https://github.com/xperiandri/Elmish.Uno/runs/6379204478?check_suite_focus=true#step:4:40)62: The "Microsoft.Build.Packaging.Pri.Tasks.ExpandPriContent" task could not be loaded from the assembly C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.300\\Microsoft\VisualStudio\v17.0\AppxPackage\\Microsoft.Build.Packaging.Pri.Tasks.dll. Could not load file or assembly 'C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.300\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.Build.Packaging.Pri.Tasks.dll'. The system cannot find the path specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\a\Elmish.Uno\Elmish.Uno\src\Elmish.Uno\Elmish.Uno.fsproj] Elmish.Uno.Tests -> D:\a\Elmish.Uno\Elmish.Uno\src\Elmish.Uno.Tests\bin\Release\net6.0\Elmish.Uno.Tests.dll

Build FAILED.

C:\Users\runneradmin\.nuget\packages\microsoft.windowsappsdk\1.0.3\buildTransitive\MrtCore.PriGen.targets(891,5): error MSB4062: The "Microsoft.Build.Packaging.Pri.Tasks.ExpandPriContent" task could not be loaded from the assembly C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.300\\Microsoft\VisualStudio\v17.0\AppxPackage\\Microsoft.Build.Packaging.Pri.Tasks.dll. Could not load file or assembly 'C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.300\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.Build.Packaging.Pri.Tasks.dll'. The system cannot find the path specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\a\Elmish.Uno\Elmish.Uno\src\Elmish.Uno\Elmish.Uno.fsproj]
0 Warning(s)
1 Error(s)

@Juriyx
Copy link

Juriyx commented May 10, 2022

Any workarounds?

@mattleibow
Copy link
Member Author

mattleibow commented May 11, 2022

You need to set the following properties (we set them in maui):

Library:

    <EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
    <GenerateLibraryLayout>true</GenerateLibraryLayout>

Apps:

    <WinUISDKReferences>false</WinUISDKReferences>

The most important is EnablePreviewMsixTooling as that switches to dotnet tooling. Also, could you open an issue on https://github.com/microsoft/WindowsAppSDK and you can link to this file if needed: https://github.com/dotnet/maui/blob/main/.nuspec/Microsoft.Maui.Core.props

We set some properties on maui because we know some specific values, but they may have ideas for general dotnet build support.

CC @marb2000

@codymullins
Copy link

@mattleibow to confirm, when this is fixed in the future we can remove these properties?

@mattleibow
Copy link
Member Author

Depends. The official fix right now with a non-Maui library is to set it. I cannot speak to whether the WinUI team actually wants these since EnablePreviewMsixTooling is a feature that you are enabling and it has different behaviour.

However, I would expect that some of these should at least be set to valid values after setting EnablePreviewMsixTooling=True since you are basically opting into new things, so why keep the legacy, VS-only features?

But, if you open an issue on the WindowsAppSDK repo I am sure they can provide more details as to the reasons h=behind the current defaults and the plans for any changes.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2022
@samhouts samhouts added the fixed-in-6.0.300-rc.2 Look for this fix in 6.0.300-rc.2! label Feb 17, 2023
@Eilon Eilon added the t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK) label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-6.0.300-rc.2 Look for this fix in 6.0.300-rc.2! legacy-area-desktop Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) platform/windows 🪟 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants