最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - dotnet publish CLI command fails due to a missing, deprecated NuGet Package - Stack Overflow

programmeradmin2浏览0评论

Goal

I'm attempting to publish my built .NET MAUI application from VS Code using the integrated terminal and .NET CLI. The target OS is Windows using the win-x64 Runtime ID (RID).

Problem

I can build the application using dotnet build just fine. The Windows application builds successfully to <Solution>\bin\Debug\net9.0-windows10.0.19041.0\win10-x64\<Solution>.dll.

However, when running dotnet publish -r win-x64 --output "<publishdir>", I receive the following error:

C:\<Solution Location>\<Solution>.csproj : error NU1102:
     Unable to find package Microsoft.NETCore.App.Runtime.Mono.win-x64 with version (= 9.0.2)
          - Found 104 version(s) in nuget [ Nearest version: 9.0.0-preview.7.24405.7 ]
          - Found 0 version(s) in C:\Program Files\dotnet\library-packs

What I've Tried

I attempted to install the Microsoft.NETCore.App.Runtime.Mono.win-x64 NuGet package using the VS Code NuGet: Add NuGet Package... command, the CLI command, and manually adding the package.

None of these solutions worked because the package is deprecated at version 9.0.0- preview.7.24405.7; I am using the .NET SDK at version 9.0.103:

PS C:\<Solution Location>> dotnet --list-sdks
9.0.103 [C:\Program Files\dotnet\sdk]

I've ensured that the NuGet Packages I'm referencing don't use this dependency, and I don't think they do:

.csproj:

<ItemGroup>
    // compatible w/.NET 9 according to website
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /> 
    // default MAUI Package
    <PackageReference Include="Microsoft.Maui.Controls" Version="9.0.40" /> 
    // default MAUI Package
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
    // does not have dependencies, according to Repository
    <PackageReference Include="QRCoder" Version="1.6.0" />
    // .NET system Package
    <PackageReference Include="System.Drawing.Common" Version="9.0.2" /> 
</ItemGroup>

From my research and understanding (not the best; I am an intermediate .NET user), the NuGet Package Manager will never be able to resolve this because it cannot find a version that satisfies the = 9.0.2 condition.

How can I resolve this? I could be overlooking a simple solution, but I can't seem to find any information on an error like this.

If there's any information I can add to this question, please tell me. I'm still learning the .NET framework so I don't know all the best debugging techniques.

Goal

I'm attempting to publish my built .NET MAUI application from VS Code using the integrated terminal and .NET CLI. The target OS is Windows using the win-x64 Runtime ID (RID).

Problem

I can build the application using dotnet build just fine. The Windows application builds successfully to <Solution>\bin\Debug\net9.0-windows10.0.19041.0\win10-x64\<Solution>.dll.

However, when running dotnet publish -r win-x64 --output "<publishdir>", I receive the following error:

C:\<Solution Location>\<Solution>.csproj : error NU1102:
     Unable to find package Microsoft.NETCore.App.Runtime.Mono.win-x64 with version (= 9.0.2)
          - Found 104 version(s) in nuget. [ Nearest version: 9.0.0-preview.7.24405.7 ]
          - Found 0 version(s) in C:\Program Files\dotnet\library-packs

What I've Tried

I attempted to install the Microsoft.NETCore.App.Runtime.Mono.win-x64 NuGet package using the VS Code NuGet: Add NuGet Package... command, the CLI command, and manually adding the package.

None of these solutions worked because the package is deprecated at version 9.0.0- preview.7.24405.7; I am using the .NET SDK at version 9.0.103:

PS C:\<Solution Location>> dotnet --list-sdks
9.0.103 [C:\Program Files\dotnet\sdk]

I've ensured that the NuGet Packages I'm referencing don't use this dependency, and I don't think they do:

.csproj:

<ItemGroup>
    // compatible w/.NET 9 according to website
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /> 
    // default MAUI Package
    <PackageReference Include="Microsoft.Maui.Controls" Version="9.0.40" /> 
    // default MAUI Package
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
    // does not have dependencies, according to Repository
    <PackageReference Include="QRCoder" Version="1.6.0" />
    // .NET system Package
    <PackageReference Include="System.Drawing.Common" Version="9.0.2" /> 
</ItemGroup>

From my research and understanding (not the best; I am an intermediate .NET user), the NuGet Package Manager will never be able to resolve this because it cannot find a version that satisfies the = 9.0.2 condition.

How can I resolve this? I could be overlooking a simple solution, but I can't seem to find any information on an error like this.

If there's any information I can add to this question, please tell me. I'm still learning the .NET framework so I don't know all the best debugging techniques.

Share Improve this question edited Feb 14 at 20:31 Mason Ritchason asked Feb 14 at 18:37 Mason RitchasonMason Ritchason 701 silver badge9 bronze badges 5
  • 1 I would assume you set <MauiVersion>9.0.40</MauiVersion> ? – Stephen Quan Commented Feb 15 at 4:13
  • 1 Did you check the official document about Publish a .NET MAUI app for Windows. When I used dotnet publish -r win-x64 --output "<publishdir>, I got the RuntimeIdentifier error. But I can use dotnet publish -f net9.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None to publish the app. – Liyun Zhang - MSFT Commented Feb 17 at 8:18
  • @StephenQuan I actually didn't have the MAUI version explicitly set. I added this and it did not solve the issue, but I'm sure it will help in general to have this configured. Thank you! – Mason Ritchason Commented Feb 18 at 14:17
  • @LiyunZhang-MSFT This worked for me. I will look through the dotnet publish command documentation to understand the difference between these two command option sets. What is the best way to distribute this unpackaged Windows application (I know this is a VERY open ended question; if you have some general resources to lead me in the right direction, that's what I mean)? Thank you! – Mason Ritchason Commented Feb 18 at 14:19
  • @LiyunZhang-MSFT nevermind. I was able to adapt your solution further to package to MSIX. Distributing it as a normal app now. Thank you again! – Mason Ritchason Commented Feb 18 at 15:42
Add a comment  | 

1 Answer 1

Reset to default 1

As an answer:

Please refer to the official document about Publish a .NET MAUI app for Windows.

  1. Publish a packaged .NET MAUI app for Windows with the CLI, such as:
dotnet publish -f net9.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64
  1. Publish an unpackaged .NET MAUI app for Windows with the CLI, such as:
dotnet publish -f net9.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None -p:WindowsAppSDKSelfContained=true
发布评论

评论列表(0)

  1. 暂无评论