Skip to content

NETSDK1145: 'The Apphost pack is not installed' error while building C++\CLI project (targeting .NET 5) with Visual Studio 2019 16.11.1 if Visual Studio 2022 17.0.0 Preview 3.1 is installed #20109

@bairog

Description

@bairog

Hello.
I have C++\CLI project (targeting .NET 5) that was building correctly with latest Visual Studio 2019 16.11.1 yesterday.
Today I've installed Visual Studio 2022 17.0.0 Preview 3.1 (than includes .NET 6 preview 7). And today I cannot build my project:

C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkRefere
nceResolution.targets(127,5): NETSDK1145: The Apphost pack is not installed and NuGet package restore is not supported. Upgrade Visual Studio, remove global.json if it specifies a certain SDK version, and uninstall the newer SDK. For more options visit https://aka.ms/targeting-apphost-pack-missing Pack Type: Apphost, Pack directory: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x86, targetframework: net5.0, Pack PackageId: Microsoft.NETCore.App.Host.win-x86, Pack Package Version: 5.0.8.

Strange thing is that now C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Sdks\Microsoft.NET.Sdk is used to build my C++\CLI project (targeting .NET 5)..

In C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x86 the following folders are present:
image

Adding this to MyProject.vcxproj (as recommended at https://aka.ms/targeting-apphost-pack-missing) changes nothing:

<ItemGroup>
  <KnownAppHostPack Update="@(KnownAppHostPack)">
    <AppHostPackVersion Condition="'%(TargetFramework)' == 'TARGETFRAMEWORK'">5.0.9</AppHostPackVersion>
  </KnownAppHostPack>
</ItemGroup>

.NET SDK 5.0.8 refuses to install because a newer version (5.0.9) alsready present in my system.

Any help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions