Skip to content
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

The executable generated from dotnet publish -r ubuntu.16.04-x64 doesn't have "x" permission #8097

Closed
daxian-dbw opened this issue Apr 10, 2017 · 18 comments
Milestone

Comments

@daxian-dbw
Copy link

dotnet publish -r ubuntu.16.04-x64 generates an executable, however, the executable file doesn't have "x" permission.
This happens when building a stand-alone application targeting netcoreapp2.0 with dotnet-cli 2.0.0-preview1-005724. It is a regression comparing to dotnet sdk 1.0.

Steps to reproduce

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifier>ubuntu.16.04-x64</RuntimeIdentifier>
  </PropertyGroup>

</Project>

# dotnet restore
# dotnet publish -r ubuntu.16.04-x64
[/temp/console]
bash:96> bin/Debug/netcoreapp2.0/ubuntu.16.04-x64/publish/console
bash: bin/Debug/netcoreapp2.0/ubuntu.16.04-x64/publish/console: Permission denied
[/temp/console]
bash:97> dir bin/Debug/netcoreapp2.0/ubuntu.16.04-x64/publish/console
-rw-rw-r-- 1 dongbo dongbo 66412 Apr 10 14:12 bin/Debug/netcoreapp2.0/ubuntu.16.04-x64/publish/console

Expected behavior

The file bin/Debug/netcoreapp2.0/ubuntu.16.04-x64/publish/console is an executable and should have the "x" permission.

Actual behavior

It doesn't have the "x" permission.

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0-preview1-005724)

Product Information:
 Version:            2.0.0-preview1-005724
 Commit SHA-1 hash:  e391b5d5f3

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /home/dongbo/.dotnet/sdk/2.0.0-preview1-005724/
@kichalla
Copy link

cc @Eilon

@livarcocc
Copy link
Contributor

@eerhardt @ramarag can we double check that apphost.exe is properly chmoded? I wonder if the change we made in the SDK for it broke this scenario.

@livarcocc
Copy link
Contributor

@eerhardt Is this exe pulled out of the nuget cache or out of the CLI build location? Wondering if there is anything we can do to work around this problem during publish.

@eerhardt
Copy link
Member

It is pulled out of the nuget cache, like always.

Wondering if there is anything we can do to work around this problem during publish.

We could, but that doesn't solve every other scenario that needs to get executables/scripts out of nuget packages. I would rather we ask NuGet or corefx to fix this issue, so it gets solved for everyone.

daxian-dbw referenced this issue in PowerShell/PowerShell Apr 17, 2017
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
@Eilon
Copy link
Member

Eilon commented Apr 17, 2017

CLI folks: Is this planned to be fixed for Preview1? I think this could be a ship-blocker, no?

cc @livarcocc

@muratg
Copy link

muratg commented Apr 24, 2017

ping

@eerhardt
Copy link
Member

@muratg - please ping @rrelyea. This is a NuGet bug: NuGet/Home#4424

@tmds
Copy link
Member

tmds commented Apr 27, 2017

@eerhardt Why is this a NuGet bug? How does NuGet affect the executable file generated by the dotnet publish command?

@dasMulli
Copy link
Contributor

How does NuGet affect the executable file

I think the idea is that NuGet should create the files in the package cache with proper permissions and record permissions on pack.

I'd like to see a more comprehensive fix in the SDK that sets the proper permission on *nix machines, not assuming that the package cache can even have those flags (depending on file system, umask etc.)

@tmds
Copy link
Member

tmds commented Apr 27, 2017

@dasMulli For pack, I understand the relationship. My question is how publish is related to NuGet.

@dasMulli
Copy link
Contributor

It just copies / renames the dotnet / apphost executable from the cache

@RheaAyase
Copy link
Member

RheaAyase commented Apr 27, 2017

Just for the sake of OCD, could we just remove the ubuntu refence from the title of this issue and have it something like dotnet/cli#6437 ?

@eerhardt
Copy link
Member

My question is how publish is related to NuGet.

We don't create the apphost executable during "publish". It is created when we build dotnet/core-setup and then put into a NuGet package.

"publish" takes assets and copies them to your publish folder. It can't know what the permissions should be for all the assets that it copies. Say a NuGet package has a .sh script in it and you need to invoke it in your app. How is publish supposed to know to make that executable?

Or say (even more likely) a NuGet package has a .sh tool script in it, and it needs to be invoked during the build. (or some other executable like crossgen)

The underlying issue here is that when I create a NuGet package, the .nupkg should retain the permissions at the time it was created. Then when the .nupkg is restored, it should be restored with the same file permissions.

Can we work around this in publish just for the apphost executable? Yes. But then the next scenario comes along that needs to execute a file and is broken. So why add all these little workarounds to every place that needs to execute a file, and instead fix the underlying issue.

@tmds
Copy link
Member

tmds commented Apr 27, 2017

@dasMulli @eerhardt thanks, relationship is clear now.

@livarcocc
Copy link
Contributor

I agree with @eerhardt, we should not go around adding one workaround after another. I will close this issue and we will track this fix through NuGet/Home#4424.

@muratg
Copy link

muratg commented May 4, 2017

@livarcocc FWIW NuGet/Home#4424 is closed. Do we need another issue to track?

@eerhardt
Copy link
Member

eerhardt commented May 5, 2017

When is a new drop of NuGet coming into the .NET Core SDK?

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants