visual studio – MAUI project not building on F5 after changes to the XAML, but it used to


When I make a change to the XAML of my project (say change the text in a label) the changes are reflected in the runnning app but if I re-run the app I get the old version of the file. If I build the App before I run it I get the new version. It seems that VS is not picking up the fact that a file has changed and it needs to rebuild, the Output (Build) window seems to confirm that as there is no mention of the Build just the Deployment. Even after closing and re-opening the project just pressing F5 gives me the old file, I have to hit build to get the new file.

Configuration manager is set to Build and Deploy for Debug.

enter image description here

I cant see anything obvious in Propject Properties
or Launch Profiles.

enter image description here

I have re-installed VS (Microsoft Visual Studio Community 2022 (64-bit) – Preview
Version 17.10.0 Preview 5.0)
I have logged out of OneDrive in case it was some sort of syncing problem.

I created a new vanilla MAUI app and that seems to work correctly which made me suppose that it was some kind of project setting causing this, so I looked at the project file, which seems to me (and I really have no clue about this but..) it looks a complete mess!! There are Includes, Removes and Updates everywhere, maby thats correct, I dont know.

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <!--<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>-->

        <!--<TargetFrameworks>net8.0-ios;net8.0-maccatalyst</TargetFrameworks>-->
        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
        <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
        <!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->

        <!-- Note for MacCatalyst:
        The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
        When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
        The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
        either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
        <!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

        <OutputType>Exe</OutputType>
        <RootNamespace>PropertyManagement</RootNamespace>
        <UseMaui>true</UseMaui>
        <SingleProject>true</SingleProject>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>

        <!-- Display name -->
        <ApplicationTitle>PropertyManagement</ApplicationTitle>

        <!-- App Identifier -->
        <ApplicationId>com.companyname.propertymanagement</ApplicationId>

        <!-- Versions -->
        <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
        <ApplicationVersion>1</ApplicationVersion>

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
        <Configurations>Debug;Release</Configurations>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.19041.0|AnyCPU'">
      <Optimize>True</Optimize>
    </PropertyGroup>

    <ItemGroup>
        <!-- App Icon -->
        <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

        <!-- Splash Screen -->
        <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

        <!-- Images -->
        <MauiImage Include="Resources\Images\*" />
        <MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

        <!-- Custom Fonts -->
        <MauiFont Include="Resources\Fonts\*" />

        <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
        <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
    </ItemGroup>

    <ItemGroup>
      <Compile Remove="Accounts\**" />
      <EmbeddedResource Remove="Accounts\**" />
      <MauiCss Remove="Accounts\**" />
      <MauiXaml Remove="Accounts\**" />
      <None Remove="Accounts\**" />
    </ItemGroup>

    <ItemGroup>
      <Compile Remove="Agreements\Agreements.xaml.cs" />
      <Compile Remove="Models\PropertyType.cs" />
      <Compile Remove="Templates\DataTemplates\PropertyViewItemTemplate.xaml.cs" />
      <Compile Remove="Templates\DataTemplates\TenantViewItemDataTemplate.xaml.cs" />
      <Compile Remove="Services\DataSharing\AgreementData.cs" />
    </ItemGroup>

    <ItemGroup>
      <None Remove="Resources\Images\pexels1029599.jpg" />
      <None Remove="Resources\Images\pexels208736.jpg" />
      <None Remove="Resources\Images\pexels259588.jpg" />
      <None Remove="Resources\Images\pexels280222.jpg" />
      <None Remove="Resources\Images\remove.png" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
        <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
        <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
        <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
        <PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
        <PackageReference Include="SQLiteNetExtensions" Version="2.1.0" />
        <PackageReference Include="SQLiteNetExtensions.Async" Version="2.1.0" />
        <PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.8" />
    </ItemGroup>

    <ItemGroup>
      <Compile Update="MyControls\PropertyTypePickerControl.xaml.cs">
        <DependentUpon>PropertyTypePickerControl.xaml</DependentUpon>
      </Compile>
      <Compile Update="RentalProperties\AddNewProperty.xaml.cs">
        <DependentUpon>AddNewProperty.xaml</DependentUpon>
      </Compile>
      <Compile Update="RentalProperties\PropertyList.xaml.cs">
        <DependentUpon>PropertyList.xaml</DependentUpon>
      </Compile>
      <Compile Update="RentalProperties\PropertiesPage.xaml.cs">
        <DependentUpon>PropertiesPage.xaml</DependentUpon>
      </Compile>
      <Compile Update="Tenants\TenantsPage.xaml.cs">
        <DependentUpon>TenantsPage.xaml</DependentUpon>
      </Compile>
      <Compile Update="Agreements\Templates\AgreementList_Item_UITemplate.xaml.cs">
        <DependentUpon>AgreementList_Item_UITemplate.xaml</DependentUpon>
      </Compile>
      <Compile Update="Dictionaries\TenantList_ItemTemplate.xaml.cs">
        <DependentUpon>TenantListItemTemplate.xaml</DependentUpon>
      </Compile>
      <Compile Update="Templates\DataTemplates\LetPropertyViewItemDataTemplate.xaml.cs">
        <DependentUpon>LetPropertyViewItemDataTemplate.xaml</DependentUpon>
      </Compile>
      <Compile Update="Templates\DataTemplates\UnLetPropertyViewItemDataTemplate.xaml.cs">
        <DependentUpon>UnLetPropertyViewItemDataTemplate.xaml</DependentUpon>
      </Compile>
      <Compile Update="Tenants\AddNewTenant.xaml.cs">
        <DependentUpon>AddNewTenant.xaml</DependentUpon>
      </Compile>
      <Compile Update="Agreements\AddNewAgreement.xaml.cs">
        <DependentUpon>AddNewAgreement.xaml</DependentUpon>
      </Compile>
      <Compile Update="Tenants\TenantList.xaml.cs">
        <DependentUpon>TenantListView.xaml</DependentUpon>
      </Compile>
      <Compile Update="Resources\Styles\ButtonStyles.xaml.cs">
        <DependentUpon>ButtonStyles.xaml</DependentUpon>
      </Compile>
    </ItemGroup>

    <ItemGroup>
      <MauiXaml Update="Agreements\Templates\AgreementList_DataTemplate.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="MyControls\PropertyTypePickerControl.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Agreements\AgreementList.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="RentalProperties\PropertyList.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Agreements\Templates\AgreementList_Item_UITemplate.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Templates\ControlTemplates\RadioButtonTemplate.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Dictionaries\TenantList_ItemTemplate.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Widgets\PropertiesWidget.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Dashboard.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="RentalProperties\DeleteProperty.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="RentalProperties\PropertiesPage.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Tenants\TenantsPage.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="RentalProperties\AddNewProperty.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Tenants\AddNewTenant.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Agreements\AddNewAgreement.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Tenants\TenantList.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="Resources\Styles\ButtonStyles.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
    </ItemGroup>

    <ItemGroup>
      <Folder Include="Accounts\ViewModels\" />
      <Folder Include="Suppliers\Templates\" />
      <Folder Include="Suppliers\ViewModels\" />
      <Folder Include="Widgets\ViewModels\" />
    </ItemGroup>

    <ItemGroup>
      <PRIResource Remove="Accounts\**" />
    </ItemGroup>

    <ItemGroup>
      <MauiXaml Remove="Agreements\Agreements.xaml" />
      <MauiXaml Remove="Templates\DataTemplates\PropertyViewItemTemplate.xaml" />
      <MauiXaml Remove="Templates\DataTemplates\TenantViewItemDataTemplate.xaml" />
    </ItemGroup>

    <ItemGroup>
      <Compile Include="Accounts\ContentPages\AccountsHomePage.xaml.cs">
        <DependentUpon>AccountsHomePage.xaml</DependentUpon>
      </Compile>
    </ItemGroup>

    <ItemGroup>
      <MauiXaml Include="Accounts\ContentPages\AccountsHomePage.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
    </ItemGroup>

</Project>

I commented out everything that was directly related to my code but no difference. Tried deleting the .vs file, no difference.

Now at a brick wall. Any help is really appreciated

Leave a Reply

Your email address will not be published. Required fields are marked *