VS2022 - Unable to optimize assemblies for performance

Jean-Marc Flamand 31 Reputation points
2023-01-01T13:55:26.72+00:00

I Have Maui class libraries that compile with no error when the following configuration manager (Debug, Any CPU).

When I build the solution with this configuration manager setting Release, AnyCPU I get the following error on all projects.

Error code: NETSDK1094
Description : Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the PublishReadyToRun property to false, or use a supported runtime identifier when publishing. When targeting .NET 6 or higher, make sure to restore packages with the PublishReadyToRun property set to true.

I do not understand how to fix it.
Can you help me on this issue ?

Here the repos location: here

Here a csproj file:

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

<PropertyGroup>  
	<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>  
	<UseMaui>true</UseMaui>  
	<SingleProject>true</SingleProject>  
	<ImplicitUsings>enable</ImplicitUsings>  

	<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>  
	<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</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>  
	<Title>Mass Propreties Calculator File Picker Maui Library</Title>  
	<PackageIcon>LogoBlanc7jtfCode400x400.png</PackageIcon>  
	<PackageLicenseExpression>MIT</PackageLicenseExpression>  
	<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>  
	<FileVersion>1.0.1.12-beta</FileVersion>  
	<AssemblyVersion></AssemblyVersion>  
	<RepositoryUrl>https://github.com/JeanMarcFlamand/MassPropertiesNugetPackages</RepositoryUrl>  
	<PackageReleaseNotes>add repository URL</PackageReleaseNotes>  
	<Platforms>AnyCPU;x64</Platforms>  
</PropertyGroup>  

<PropertyGroup>  
  <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>  
  <PackageTags>Mass Properties; Weight and Balance; Weight;Center of Gravity;Inertia; Mass;</PackageTags>  
  <Authors>Jean-Marc Flamand</Authors>  
  <Company>7jtfCode</Company>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-android|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
  <DebugSymbols>True</DebugSymbols>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-android|x64'">  
  <ApplicationTitle />  
  <DebugSymbols>True</DebugSymbols>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-android|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
  <DebugSymbols>True</DebugSymbols>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-android|x64'">  
  <ApplicationTitle />  
  <DebugSymbols>True</DebugSymbols>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-maccatalyst|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-maccatalyst|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-maccatalyst|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-maccatalyst|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-tizen|AnyCPU'">  
  <ApplicationTitle>MPC File Picker Library</ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-tizen|x64'">  
  <ApplicationTitle>MPC File Picker Library</ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-tizen|AnyCPU'">  
  <ApplicationTitle>MPC File Picker Library</ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-tizen|x64'">  
  <ApplicationTitle>MPC File Picker Library</ApplicationTitle>  
</PropertyGroup>  

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

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-windows10.0.19041.0|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-windows10.0.19041.0|AnyCPU'">  
  <ApplicationTitle></ApplicationTitle>  
</PropertyGroup>  

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-windows10.0.19041.0|x64'">  
  <ApplicationTitle />  
</PropertyGroup>  

<ItemGroup>  
  <None Include="D:\7JTFCode\Logo2022\LogoBlanc7jtfCode400x400.png">  
    <Pack>True</Pack>  
    <PackagePath>\</PackagePath>  
  </None>  
</ItemGroup>  

</Project>

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,594 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,854 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Garth 5,801 Reputation points
    2023-01-01T16:41:35.023+00:00

    Ok, I will bite, what does this have to do with configmgr app? E.g. I think you picked the wrong tags.


  2. BDisp 0 Reputation points
    2023-01-18T19:41:41.7566667+00:00

    I also was facing this issue and found the cause was the sdk version of the global.json pointing to a non existing runtime version. So, if the version is set to 7.0.100 and the machine only have the 7.0.102 installed, then this issue will arise. The solution is change the sdk version to 7.0.102 or install the sdk version 7.0.100.

    0 comments No comments

  3. Kerry W. Lothrop 0 Reputation points MVP
    2023-01-26T10:23:41.83+00:00

    I am having the same issue and would really appreciate a public answer.

    0 comments No comments

  4. Idrees 0 Reputation points
    2023-02-10T11:17:49.0733333+00:00

    I also have the same issue and would like an answer

    0 comments No comments

  5. Esteban Vidal 0 Reputation points
    2023-02-27T10:23:38.92+00:00

    Same issue here, any update?

    0 comments No comments