How to have app.xaml & *.xaml files listed in .csproj when using upgrade assistant to migrate from 4.5 to 6.0

devarakonda ramakrishna 0 Reputation points
2023-05-02T17:29:46.8333333+00:00

I am using Microsoft's upgrade assistant to migrate projects from 4.5 to 6.0. I am able to have ".cs" files included in the .csproj file by default by modifying the values of "EnableDefaultItems", "EnableDefaultCompileItems" to false in Microsoft.NET.Sdk.DefaultItems.targets. But for app.xaml & *.xaml files I am not able to find a similar setting that works. I tried modifying "EnableDefaultPageItems" & "EnableDefaultApplicationDefinition" to false in Microsoft.NET.Sdk.WindowsDesktop.targets but no luck.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,762 questions
{count} votes

1 answer

Sort by: Most helpful
  1. devarakonda ramakrishna 0 Reputation points
    2023-05-03T11:24:46.91+00:00

    No,

    This is what I had in the new .csproj even after adding the suggested file.

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net7.0-windows</TargetFramework>
        <OutputType>WinExe</OutputType>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
        <UseWPF>true</UseWPF>
        <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
      </PropertyGroup>
      <ItemGroup>
        <Compile Include="Class1.cs" />
        <Compile Include="Class2.cs" />
      </ItemGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
        <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
        <PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302">
          <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.1" />
      </ItemGroup>
    </Project>
    
    

    The below are still missing from .csproj file

    <Compile Include="UserControl1.xaml.cs">
          <DependentUpon>UserControl1.xaml</DependentUpon>
        </Compile>
        <Page Include="MainWindow.xaml">
          <Generator>MSBuild:Compile</Generator>
          <SubType>Designer</SubType>
        </Page>
        <Compile Include="App.xaml.cs">
          <DependentUpon>App.xaml</DependentUpon>
          <SubType>Code</SubType>
        </Compile>
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.