New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`dotnet pack` fails on .NET Core project when `paket.references` contains only File: references #2623

magne opened this Issue Aug 17, 2017 · 1 comment


None yet
2 participants

magne commented Aug 17, 2017


When building a .NET Core project with a paket.references only containing File: references, running dotnet pack will fail rather than producing a NuGet package.

The reason the build will fail is that no intermediate paket reference file is produced (would be src\TestProj\obj\TestProj.csproj.references in this case). This in turn causes .paket\Paket.Restore.targets to fail on line 87.

Repro steps

Given the following .Net Core .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
        <Compile Include="..\..\paket-files\MiniProfiler\dotnet\StackExchange.Profiling\Data\ExecuteType.cs">
        <Compile Include="..\..\paket-files\MiniProfiler\dotnet\StackExchange.Profiling\Data\IDbProfiler.cs">
    <Import Project="..\.paket\Paket.Restore.targets"/>



github MiniProfiler/dotnet:v3 StackExchange.Profiling/Data/ExecuteType.cs
github MiniProfiler/dotnet:v3 StackExchange.Profiling/Data/IDbProfiler.cs

and paket.references:


When running

dotnet pack

the build will produce an error.

...> dotnet --info
.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

...> .paket\paket.exe --version
Paket version 5.85.3

Expected behavior

The build should produce a NuGet package.

Actual behavior

The build fails with the following error:

...> dotnet pack
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  TestProj -> xxx\src\TestProj\bin\Debug\net461\TestProj.dll
  Paket version 5.85.3
   - Runtime: 665 milliseconds
  Paket failed with
  -> Specified references-file 'xxx\src\TestProj/obj/TestProj.csproj.references' does not exist.
xxx\.paket\Paket.Restore.targets(87,5): error MSB3073: The command ""xxx\.paket\paket.exe" fix-nuspecs files "obj\TestProj.1.0.0.nuspec" references-file "xxx\src\TestProj/obj/TestProj.csproj.references" " exited with code 1. [xxx\src\TestProj\TestProj.csproj]

If the .csproj file specifies the property <IsPackable>false</IsPackable> the error is

...> dotnet pack
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

xxx\.paket\Paket.Restore.targets(94,5): error MSB4044: The "PackTask" task was not given a value for the required parameter "PackItem". [xxx\src\TestProj\TestProj.csproj]

but this would be fixed by #2621.

Known workarounds

Adding the following target to either .paket\Paket.Restore.targets or your .csproj file will make the build produce a NuGet package:

    <Target Name="CreatePaketReferencesFile" AfterTargets="GenerateNuspec" BeforeTargets="PaketOverrideNuspec" Condition="'$(IsPackable)' == '' Or '$(IsPackable)' == 'true'" >
        <Touch Files="$(PaketReferencesFilePath)" AlwaysCreate="true" />

Another solution might be to add the following condition to the PaketDisableDirectPack and PaketOverrideNuspec targets in .paket\Paket.Restore.targets:

<Target Name="..." Condition="($(IsPackable) == '' Or $(IsPackable) == 'true') And Exists('$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references')">

This has the added benefit that paket is not invoked, increasing performance.

I have no idea which of these workarounds is best.


This comment has been minimized.

Show comment
Hide comment

forki Aug 17, 2017


Second sounds good. Can you please send a pull request?


forki commented Aug 17, 2017

Second sounds good. Can you please send a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment