Skip to content

Editing WinUI projects created with older versions of the extension requires manual changes #4582

@mikebattista

Description

@mikebattista

Describe the bug

Due to significant changes in the project templates, we recommend creating a new project with the 5.2 extension and migrating your old project to the new template in order to edit projects.

Editing existing projects is possible but will require manual changes to resolve merge conflicts and other build issues.

  • For Navigation View projects, rename SplitView to NavView in Package.appxmanifest and/or TemplateStudio.xml.
    • Without this change, the Edit Project wizard will be broken
  • Add <ImplicitUsings>enable</ImplicitUsings> to the App and Core project files
    • Fully qualify UnhandledExceptionEventArgs in App.xaml.cs with the Microsoft.UI.Xaml namespace
  • Add <Nullable>enable</Nullable> to the App and Core project files (optional)
    • Without this change, you will receive compiler messages about nullable reference types
    • With this change, you will likely need to update existing code to avoid further messages
  • Add a NuGet package reference to WinUIEx and a Usings.cs file with global using WinUIEx;
  • Add MainWindow.xaml to your project from a project created with the 5.2 extension
    • Update the namespace references in the xaml and cs files to match your existing project namespace
    • Set MainWindow.xaml Build Action to Page in the Properties window
  • Update App.xaml.cs to match the structure of the version from a project created with the 5.2 extension
    • Refactor Host, GetService, and MainWindow
    • Add .UseContentRoot(AppContext.BaseDirectory) after CreateDefaultBuilder()

If you encounter other issues with editing projects created with older versions of the extension, add a comment below and we'll update the guidance here with the manual changes required.

To Reproduce

  1. Create a project with Template Studio version <= 5.1
  2. Edit the project with Template Studio version >= 5.2

Additional context

No response

Applies to the following platforms:

  • WinUI
  • WPF
  • UWP

About your setup

  • Visual Studio Version:
  • Template Studio Wizard Version:
  • Windows Build:

Metadata

Metadata

Assignees

Labels

bugThe issue relates to the wizard not working or a problem with the generated code.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions