Search code examples
c#vb.netpublishmaui

Application runs in debugging but publishing fails


I have created solution with two projects:

Project1.csproj (using C#):

<PropertyGroup>
    <TargetFrameworks>net7.0-maccatalyst;net7.0-ios;net7.0-android</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
    <OutputType>Exe</OutputType>
    <UseMaui>true</UseMaui>
    <SingleProject>true</SingleProject>
    <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
  <ProjectReference Include="..\Smanager\Smanager.vbproj" />
</ItemGroup>

Project2.csproj (using visual basic):

<PropertyGroup>
    <RootNamespace>Smanager</RootNamespace>
    <TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

Everything runs perfectly in debugging and release, my application works perfectly fine and breakpoints in both projects are triggered. However once I am trying to Publish my app, I am getting an error below. Before adding Project2, everything was also working fine and publishing succeeded every time. What might be wrong and how to fix it? I have already tried to clean solution, restart VS, rebuild, delete hidden .vs folder, set projects to build separately in solution properties, reinstall VS.

This is an output of publishing attempt:

1>1 of 2 projects are up-to-date for restore.
1>Cannot resolve Assembly or Windows Metadata file 'C:\Users\...\bin\Release\net7.0\Smanager.dll'
1>Metadata file 'C:\Users\...\bin\Release\net7.0\Smanager.dll' could not be found
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:18.234 ==========
========== Package: 0 succeeded, 1 failed ===========

Solution

  • Answer to this is to delete publishing profile. Even thought it is similar, just go to:

    1. Your Startup project
    2. Properties
    3. PublishProfiles
    4. Right click and delete all existing profiles
    5. Clean solution
    6. Start Publishing from the start

    enter image description here