Skip to content

Executables restored from NuGet packages are no longer executable with .NET Core "2.0" #4424

Closed

Description

@eerhardt

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):

Erics-MBP:cli eerhardt$ ./.dotnet_stage0/x64/dotnet --info
.NET Command Line Tools (2.0.0-alpha-004622)

Product Information:
 Version:            2.0.0-alpha-004622
 Commit SHA-1 hash:  1f44cabf4a

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.11-x64

Worked before? If so, with which NuGet version: Yes, with dotnet restore version 1.0.0-rc3-004530.

Detailed repro steps so we can see the same problem

  1. Install a "2.0" CLI from https://github.com/dotnet/cli/tree/master#installers-and-binaries on a non-Windows machine.

  2. Restore a package that contains a tool/executable. For example, Microsoft.NETCore.Runtime.CoreCLR version 1.2.0-beta-24904-03.

  3. Try to execute the crossgen executable at .nuget/packages/runtime.osx.10.10-x64.microsoft.netcore.runtime.coreclr/1.2.0-beta-24904-03/tools/crossgen

Expected result:

With "1.0", the executable would run.

Actual result:

15:57:11.104     1>/Users/dotnet-bot/j/workspace/dotnet_cli/master/release_osx_x64_prtest/build/Microsoft.DotNet.Cli.Compile.targets(225,7): error MSB6003: The specified task executable "crossgen" could not be run. Operation not permitted [/Users/dotnet-bot/j/workspace/dotnet_cli/master/release_osx_x64_prtest/build.proj]

Notes

The regression is caused by System.IO.Compression in corefx. See https://github.com/dotnet/corefx/issues/15516. In .NET Core 2.0, the Zip APIs are no longer setting the "x" mod on files unzipped.

This is going to be an issue for all tooling using NuGet to restore executables on non-Windows platforms. We shouldn't expect every place that is executing programs from NuGet packages to have to ensure the file has an "x" permission on it.

Activity

  1. added a commit that references this issue on Jan 28, 2017
  2. added this to the milestone on Jan 30, 2017
  3. rrelyea commented on Jan 30, 2017

    @rrelyea
    Contributor

    Any reason this is a shipstopper for rtm?

  4. eerhardt commented on Jan 30, 2017

    @eerhardt
    Author

    Not a shipstopper. This only affects "2.0". "1.0" works fine.

  5. eerhardt commented on Feb 28, 2017

    @eerhardt
    Author

    @rrelyea - when VS 2017 is out the door, can we get this issue triaged? This is going to affect a lot of "2.0" scenarios, so I'd like to get it fixed early in "2.0".

  6. eerhardt commented on Mar 1, 2017

    @eerhardt
    Author

    For example, this is breaking the dotnet cache feature on non-Windows machines in 2.0 because the crossgen executable is not marked with the "x" permission.

    @gkhanna79 @ramarag

  7. eerhardt commented on Mar 3, 2017

    @eerhardt
    Author

    Shell scripts need to be marked executable as well.

    /cc @livarcocc

  8. eerhardt commented on Apr 14, 2017

    @eerhardt
    Author

    @rrelyea - as we are getting more people using .NET Core 2.0, this is becoming more of an issue. See https://github.com/dotnet/cli/issues/6286. Can we get this looked into?

  9. eerhardt commented on Apr 14, 2017

    @eerhardt
    Author
  10. Eilon commented on Apr 24, 2017

    @Eilon

    @rrelyea - this issue blocks ASP.NET Core (and presumably other) apps from running after running the publish operation. Do we have an idea when we might see a fix for this?

  11. muratg commented on Apr 24, 2017

    @muratg

    👀

  12. 27 remaining items

  13. tmds commented on Jun 9, 2017

    @tmds
  14. gkhanna79 commented on Jun 9, 2017

    @gkhanna79
  15. gkhanna79 commented on Jun 9, 2017

    @gkhanna79

    If the possible cause identified by @tmds is correct, then this issue has been present for standalone publish in Preview1 as well and fix would be to set the X bit once the modified binary is published.

    @steveharter can you PTAL?

  16. gkhanna79 commented on Jun 9, 2017

    @gkhanna79

    @kichalla Can you please file an issue in SDK for your repro above and assign it to @eerhardt and @steveharter?

  17. tmds commented on Jun 9, 2017

    @tmds

    or alternatively, the apphost can be placed in the publish folder using File.Copy and renamed using File.Move.

  18. gkhanna79 commented on Jun 9, 2017

    @gkhanna79

    Apphost needs to be modified as part of publish operation so simply copying is not going to work.

  19. tmds commented on Jun 9, 2017

    @tmds

    You can open the copied file

  20. gkhanna79 commented on Jun 9, 2017

    @gkhanna79

    @livarcocc When CLI published a standalone app, does it ever mark its entrypoint executable with the "X" bit on non-Windows?

  21. steveharter commented on Jun 9, 2017

    @steveharter

    Taking a look now

  22. steveharter commented on Jun 9, 2017

    @steveharter

    My understanding:

    • Only the modified apphost executable needs the +x; other executables are now properly restored from nuget.
    • This only occurs (the x is lost) during publish of a standalone app, when copying the source apphost to the destination\modified apphost

    I am still going through the repro steps; clearing the nuget cache and then restore is being very slow...

  23. gkhanna79 commented on Jun 9, 2017

    @gkhanna79
  24. livarcocc commented on Jun 9, 2017

    @livarcocc

    If the file is signed in the NuGet package, why is it losing that permission? It seems like these permissions should not be lost when copying/moving the file. And explicitly setting it in the SDK seems like a workaround for an issue somewhere else.

  25. kichalla commented on Jun 9, 2017

    @kichalla

    @kichalla Can you please file an issue in SDK for your repro above and assign it to @eerhardt and @steveharter?

    dotnet/sdk#1331

  26. tmds commented on Jun 12, 2017

    @tmds

    If the file is signed in the NuGet package, why is it losing that permission? It seems like these permissions should not be lost when copying/moving the file.

    @livarcocc This is the code which is 'copying' the app host: https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/EmbedAppNameInHost.cs#L62. It is creating a new file from bytes in memory.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions