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

The PRIResource build action is needed by the .NET 5 project system, despite EnableDefaultItems being true by default, for resources to be added to the PRI on build. #15007

Closed
rohanp-msft opened this issue Dec 16, 2020 · 2 comments
Assignees
Labels
untriaged Request triage from a team member

Comments

@rohanp-msft
Copy link
Contributor

Visual Studio Version: VS 2019 Preview (Version 16.9.0 Preview 1.0)

Summary:
Despite EnableDefaultItems being true by default in the .NET 5 project system, the .csproj file of a WinUI3 Preview 3 project requires the PRIResource build action for resources to be added to the PRI file on build.

Steps to Reproduce:

  1. Install WinUI3 Preview 3 per the instructions here: https://docs.microsoft.com/en-us/windows/apps/winui/winui3/#install-winui-3-preview-3

  2. Create a new project using the "Class Library (WinUI in Desktop)" WinUI template (the same issue occurs with other WinUI3 Preview 3 templates, I'm just using this as an example).

  3. Right click on the project in Solution Explorer. Select Add -> New Item... Select "Resources File (.resw)" in the list displayed. Add any value for the "String1" resource in the UI. Save the file.

  4. Notice that the .csproj file now contains these two nodes:

  <ItemGroup>
    <None Remove="Resources.resw" />
  </ItemGroup>

and

  <ItemGroup>
    <PRIResource Include="Resources.resw" />
  </ItemGroup>
  1. Hit Build. Dump the PRI file that's generated using the following example command:
    & 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\makepri.exe' dump /if "<my_user_dir_path>\source\repos\ClassLibrary1\bin\Debug\net5.0-windows10.0.18362.0\ClassLibrary1.pri" /of "<my_user_dir_path>\source\repos\ClassLibrary1\bin\Debug\net5.0-windows10.0.18362.0\ClassLibrary1.pri.xml"
    You'll see that the string that was added to the .resw file is present in the PRI dump.

  2. Now, go to the .csproj file. Remove the PRIResource build action. Rebuild the project. Dump the PRI again.

Expected Behavior:
PRI does contain string resources.
None and PRIResource should not be needed in the .csproj file since EnableDefaultItems is true by default in the .NET 5 project system.

Actual Behavior:
PRI does not contain string resources.

User Impact:
On migration from WinUI Preview 2 to Preview 3 (WinUI3 Preview 2 used pre .NET 4, and WinUI3 Preview 3 uses .NET 5), the user needs to manually add the PRIResource build action to the project file for the string resources to show up in the PRI. Before migration, a PRIResource build action wasn't needed; after it is. Example: microsoft/microsoft-ui-xaml#3648

@rohanp-msft rohanp-msft changed the title The PRIResource build action is needed by the .NET 5 project system despite EnableDefaultItems being true by default for resources to be added to the PRI on build. The PRIResource build action is needed by the .NET 5 project system, despite EnableDefaultItems being true by default, for resources to be added to the PRI on build. Dec 16, 2020
@drewnoakes
Copy link
Member

I believe this issue belongs to the SDK. The project system doesn't have anything to do with EnableDefaultItems.

@drewnoakes drewnoakes transferred this issue from dotnet/project-system Dec 16, 2020
@marcpopMSFT marcpopMSFT added the untriaged Request triage from a team member label Feb 17, 2021
@rohanp-msft
Copy link
Contributor Author

This will be addressed through microsoft/WindowsAppSDK#613.
This issue isn't migration specific.
It can be addressed correctly by the Project Reunion MSBuild props file.
That's the solution we're going with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

4 participants