Home: Nuget doesn't restore a net461 project failing the build

Created on 13 Jan 2017  路  2Comments  路  Source: NuGet/Home

Using dotnet cli 1.0.0-preview5-004478.
Create a csproj with the following content:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
  </PropertyGroup>
</Project>

Try to build:

>dotnet restore
  Nothing to do. None of the projects specified contain packages to restore.
>dotnet build
Microsoft (R) Build Engine version 15.1.509.30326
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\1.0.0-preview5-004478\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(113,5): error : Assets file 'C:\Users\martin.ullrich\Downloads\TmpProj\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\Users\martin.ullrich\Downloads\TmpProj\TmpProj.csproj]

Workaround:
Change TargetFramework to TargetFrameworks => restore will produce an assets file.

dotnet --info:

>dotnet --info
.NET Command Line Tools (1.0.0-preview5-004478)

Product Information:
 Version:            1.0.0-preview5-004478
 Commit SHA-1 hash:  4d3e2872fe

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-preview5-004478

cc @emgarten @rrelyea (don't know better..)

Most helpful comment

@dasMulli add this property to your project file:

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

It will be set automatically by the SDK, but you may have the updated nuget.targets without the latest SDK.

All 2 comments

Seems to work with 1.0.0-rc3-004479 if you know where to get it from at the moment 馃榿

@dasMulli add this property to your project file:

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

It will be set automatically by the SDK, but you may have the updated nuget.targets without the latest SDK.

Was this page helpful?
0 / 5 - 0 ratings