dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

clearer exception when calling dotnet pack on global tool that depends on packages with `dependency` #9564

Open Mackiovello opened 6 years ago

Mackiovello commented 6 years ago

Steps to reproduce

$ dotnet new --install McMaster.DotNet.GlobalTool.Templates
$ mkdir Reproduce
$ cd Reproduce/
$ dotnet new global-tool --command-name awesome-tool
The template ".NET Core Global Console Tool" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/erlend/Desktop/Reproduce/Reproduce.csproj...
  Restoring packages for /home/erlend/Desktop/Reproduce/Reproduce.csproj...
  Generating MSBuild file /home/erlend/Desktop/Reproduce/obj/Reproduce.csproj.nuget.g.props.
  Generating MSBuild file /home/erlend/Desktop/Reproduce/obj/Reproduce.csproj.nuget.g.targets.
  Restore completed in 149.16 ms for /home/erlend/Desktop/Reproduce/Reproduce.csproj.

Restore succeeded.

$ dotnet add package runtime.native.Starcounter.Bluestar2 --version 1.0.0 --source https://www.myget.org/F/starcounter/api/v3/index.json 
  Writing /tmp/tmpkgqVAu.tmp
info : Adding PackageReference for package 'runtime.native.Starcounter.Bluestar2' into project '/home/erlend/Desktop/Reproduce/Reproduce.csproj'.
log  : Restoring packages for /home/erlend/Desktop/Reproduce/Reproduce.csproj...
info : Package 'runtime.native.Starcounter.Bluestar2' is compatible with all the specified frameworks in project '/home/erlend/Desktop/Reproduce/Reproduce.csproj'.
info : PackageReference for package 'runtime.native.Starcounter.Bluestar2' version '1.0.0' added to file '/home/erlend/Desktop/Reproduce/Reproduce.csproj'.
$ dotnet pack
Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for /home/erlend/Desktop/Reproduce/Reproduce.csproj...
  Restore completed in 165.46 ms for /home/erlend/Desktop/Reproduce/Reproduce.csproj.
  Reproduce -> /home/erlend/Desktop/Reproduce/bin/Debug/netcoreapp2.1/Reproduce.dll
  Reproduce -> /home/erlend/Desktop/Reproduce/bin/Debug/netcoreapp2.1/Reproduce.dll
  Reproduce -> /home/erlend/Desktop/Reproduce/bin/Debug/netcoreapp2.1/publish/
/usr/share/dotnet/sdk/2.1.301/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(198,5): error : The DateTimeOffset specified cannot be converted into a Zip file timestamp. [/home/erlend/Desktop/Reproduce/Reproduce.csproj]
/usr/share/dotnet/sdk/2.1.301/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(198,5): error : Parameter name: value [/home/erlend/Desktop/Reproduce/Reproduce.csproj]

The nuspec for runtime.native.Starcounter.Bluestar2 looks like this:

<?xml version="1.0"?>
<package>
    <metadata>
        <id>runtime.native.Starcounter.Bluestar2</id>
        <version>$version$</version>
        <authors>Starcounter</authors>
        <owners>Starcounter</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <copyright>©Starcounter AB. All rights reserved.</copyright>
        <description>Native binaries for Starcounter Bluestar.</description>
        <dependencies>
            <dependency id="runtime.win7-x64.runtime.native.Starcounter.Bluestar2" version="$version$" />
            <dependency id="runtime.ubuntu.16.04-x64.runtime.native.Starcounter.Bluestar2" version="$version$" />
        </dependencies>
    </metadata>
    <files>
        <file src="src/metalayer/metaschema.json" target="content/Starcounter/metaschema.json" />
    </files>
</package>

The dependencies of this package contain native dlls.

Expected behavior

dotnet pack should produce a package, or fail with a meaningful error.

Actual behavior

See above, fails with "error : The DateTimeOffset specified cannot be converted into a Zip file timestamp." and "error : Parameter name: value".

Environment data

dotnet --info output:

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.301
 Commit:    59524873d6

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.301/

Host (useful for support):
  Version: 2.1.1
  Commit:  6985b9f684

.NET Core SDKs installed:
  1.0.4 [/usr/share/dotnet/sdk]
  2.1.200 [/usr/share/dotnet/sdk]
  2.1.301 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
wli3 commented 6 years ago

Hi @Mackiovello,

  1. Currently we don't allow dependency in tools package. WIP documentation https://github.com/dotnet/cli/pull/9589
  2. Also only portable app is supported https://github.com/dotnet/cli/issues/8618

If you hope to enable dependency, could you create another issue or rename the title? It is not an easy task, so we hope to get more discussion. @KathleenDollard

Mackiovello commented 6 years ago

Hi @wli3 thanks for the answer.

Currently we don't allow dependency in tools package.

What do you mean with that? What kind of dependencies are not supported? dotnet-serve has dependencies to external dependencies: https://github.com/natemcmaster/dotnet-serve/blob/master/src/dotnet-serve/dotnet-serve.csproj

Also only portable app is supported

What's the difference between a portable app and a self-contained app?

wli3 commented 6 years ago

@Mackiovello please reference the above linked document. Dependency as in nuspec dependency. Project level dependency is allowed.

<dependencies>
            <dependency id="runtime.win7-x64.runtime.native.Starcounter.Bluestar2" version="$version$" />
            <dependency id="runtime.ubuntu.16.04-x64.runtime.native.Starcounter.Bluestar2" version="$version$" />
        </dependencies>
Mackiovello commented 6 years ago

@Mackiovello please reference the above linked document.

I understand, then I'll rename this issue to request support for dependency in nuspec files.

KathleenDollard commented 6 years ago

There are two kinds of dependencies. Dependencies that can be included in the package, and dependencies that are to external packages. Global tools supports the first.

A self contained application is a runnable app that carries a copy of the .NET Core Runtime inside itself. Global tools doesn't support this for a few reasons - we assume the user of the package wants to decide what .NET Core Runtime to use within the targeted frameworks specified by the author. Self contained apps are comparatively giant (because they contain the core). More importantly though, current global tools rely on a shim that provides the app host to run the tool.

We may support running any executable in the future (which is what is needed for self-contained apps), but are looking for scenarios to aid prioritization (repo tools, credentials, and some other features are higher).

Mackiovello commented 6 years ago

That makes sense, thanks for the explanation.

It would be neat if there was a clearer exception when this happens.

What do you want to do with this issue? I could close it as answered, or we could keep it as a feature request, or as an issue for the unclear exception.

KathleenDollard commented 6 years ago

@Mackiovello I would prefer to either close this issue or change the name to be "needs a clearer exception when..."

I would also appreciate you ensuring there is an issue for self-contained global tools, because that part is a feature request we should have if we don't already.

github-actions[bot] commented 3 weeks ago

Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.