Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot publish a self-contained dotnet-core application due to NU1100

Tags:

.net-core

I have ported a .net application to .netcore and want to publish it as a self-contained application. Unfortunately, this does not work:

dotnet publish -r win-x64
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

<Path>\IPLauncher.csproj : error NU1100: Unable to resolve 'Microsoft.NETCore.App.Runtime.win-x64 (= 3.1.2)' for '.NETCoreApp,Version=v3.1'.
<Path>\IPLauncher.csproj : error NU1100: Unable to resolve 'Microsoft.WindowsDesktop.App.Runtime.win-x64 (= 3.1.2)' for '.NETCoreApp,Version=v3.1'.
<Path>\IPLauncher.csproj : error NU1100: Unable to resolve 'Microsoft.AspNetCore.App.Runtime.win-x64 (= 3.1.2)' for '.NETCoreApp,Version=v3.1'.
  Restore failed in 179,65 ms for <Path>\IPLauncher.csproj.

In case it is important, my csproj-file looks like this:

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

</Project>

Edited to add: The weirdest part is that my colleague can publish a self-contained exe for the same project with identical configuration - so it seems to be some problem with my configuration.

like image 268
ChristophK Avatar asked Mar 11 '20 10:03

ChristophK


1 Answers

It seems like nuget restore command for your application can't restore some packages.

There are many reasons for that, but you can do basic research for determine why it's heppens. Here some tips:

  1. Clear all NuGet caches dotnet nuget locals all --clear
  2. Check if NuGet packages you trying to restore accessible from nuget.org website. Official nuget package manager website has different API's (v2/v3) so you must check you use latest version of API.
  3. If you use NuGet package not from official portal - verify that NuGet server you use for restoring nuget packages is accessible.

These settings placed in default nuget.config file here: %appdata%\NuGet\NuGet.config

Note that if you using custom nuget.config for your project/solution it's overrides default nuget settings. This file can contains some settings that breaks restore command. So check it out first.

like image 108
picolino Avatar answered Oct 17 '22 23:10

picolino