1

I'm currently trying to get a netcore application running in debian. But as soon as I run a dotnet restore I get an error. To check if dotnet was alright, I created a new project with dotnet new. A restore there works fine. But as soon as I add the reference to System.Diagnostics.FileVersionInfo, I get the following error:

/opt/dotnet/sdk/1.0.3/NuGet.targets(97,5): error : Object reference not set to an instance of an object. [/root/test/test.csproj]

The original project was developed in Windows, using Visual Studio 2017. If I do a dotnet restore there, it works fine. even if I do a dotnet restore -r debian.8-x64.

Does anyone know what's going wrong here?

The test.csproj I created for testing purposes and which also fails looks like this:

<PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
    <PackageReference Include="System.Diagnostics.FileVersionInfo" Version="4.3.0" />
  </ItemGroup>


</Project>
Filburt
  • 17,626
  • 12
  • 64
  • 115
timothy3001
  • 765
  • 2
  • 8
  • 17

1 Answers1

1

System.Diagnostics.FileVersionInfo package requires following versions for NuGet.

When using NuGet 3.x this package requires at least version 3.4.
Requires NuGet 2.12 or higher.

You can check it System.Diagnostics.FileVersionInfo

To check NuGet version just print in Terminal nuget

$ nuget
NuGet Version: 2.8.7.0
usage: NuGet <command> [args] [options] 
Type 'NuGet help <command>' for help on a specific command.

UPDATE 1 HOW TO INSTALL NUGET ON LINUX Original Answer

Once you've followed the (somewhat annoying) install steps to get .Net core installed and the apt repo setup from https://www.microsoft.com/net/core, you can just do this:

sudo apt install nuget

and you'll have a working nuget on your local machine:

$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l

$ nuget
NuGet Version: 2.8.7.0
usage: NuGet <command> [args] [options] 
Type 'NuGet help <command>' for help on a specific command.

Notice that as of the time of writing do not run nuget update -self, as although it will successfully install a more recent version of nuget, that version won't actually run.

If you do break it though, you can always just blow it away and reinstall:

sudo apt remove nuget
sudo apt install nuget
Community
  • 1
  • 1
Samvel Petrosov
  • 7,580
  • 2
  • 22
  • 46
  • Oh ok thank you, probably using a wrong nuget version then, but I'm not sure. I actually didn't need to install nuget. Correct me if I'm wrong, but doesn't dotnet have its own version of nuget integrated? If I run `dotnet nuget` I get a help screen saying "NuGet Command Line 4.0.0.0". The version of nuget if I get it from apt-get seems to be too old then. it's 2.8.1.0. – timothy3001 May 08 '17 at 08:26
  • @timothy3001 package.json in the new versions of .net core is used only for npm. NuGet is using .csproj file. – Samvel Petrosov May 08 '17 at 08:55
  • Ok thank you. Didn't look into the Ubuntu guide, only into the Debian one where they don't mention to update the apt repositories. Thanks a lot so far, trying to get the repository into my apt as well. – timothy3001 May 08 '17 at 08:59
  • Cannot install a newer NuGet version under Linux. I checked the repositories of both, Debian AND Ubuntu and both only have ancient versions of nuget... http://packages.ubuntu.com/yakkety/nuget https://packages.debian.org/jessie/nuget Is there anybody out there who REALLY tried to use net core in Linux? Either I'm blind or no one really tried to compile a real application (and not only Hello World) in linux using net core. This is really frustrating, because I cannot even find binaries for nuget or any information on that... – timothy3001 May 08 '17 at 09:31
  • 1
    @timothy3001 following the MSDN documentation you need to install .NET Core SDK, Mono and after it run NuGet on Mono https://learn.microsoft.com/en-us/nuget/guides/install-nuget – Samvel Petrosov May 08 '17 at 09:34
  • @timothy3001 I think this will help you toohttps://github.com/NuGet/Home/issues/3382 – Samvel Petrosov May 08 '17 at 09:37
  • 1
    Mhmmm thank you. I guess I'll go with that. Even though it's quite odd to install Mono and use that to have an updated version of nuget. Looks like a dirty workaround to me to be honest but I guess there's no other way. I think I'm gonna open an issue on github though, because this should be fixed properly in my opinion. Otherwise you just cannot develop properly on and for linux platforms.. – timothy3001 May 08 '17 at 10:04
  • @timothy3001 - This answer looks like a workaround to me. dotnet restore does not use the system installed NuGet to restore packages it uses its own copy of NuGet. So updating nuget that ships with Mono on Linux would not fix the dotnet restore. – Matt Ward May 08 '17 at 12:16
  • Yeah, already thought so. To be honest, I actually went over to building and publishing the app on a Windows machine by selecting `debian.8-x64` as runtime. So basically a SCD and it works! Finally some success :D I also tried using a prelease of the dotnet CLI version 2.0 on linux. Some of the errors got fixed indeed but not all of them. I created an issue on github, so maybe we get some more information about further plans on nuget and linux... It might be in the wrong place then though, if it's rather a dotnet cli problem but we will see: https://github.com/NuGet/Home/issues/5177 – timothy3001 May 08 '17 at 12:28