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

Failed to create CoreCLR if an app has ':' (colon) in the path on Mac #104402

Open
rolfbjarne opened this issue Jul 3, 2024 · 11 comments
Open

Failed to create CoreCLR if an app has ':' (colon) in the path on Mac #104402

rolfbjarne opened this issue Jul 3, 2024 · 11 comments
Labels
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented Jul 3, 2024

Simplified repro:

dotnet new console
dotnet build
ren ./bin/Debug/net9.0 net9.0:n
./bin/Debug/net9.0:n/app
Failed to create CoreCLR, HRESULT: 0x80070057

From @brunck on Mon, 01 Jul 2024 22:46:14 GMT

It's helpful to have a nuget.config file on the Windows side to shorten paths, due to the dastardly max path problem in VS for Windows. This breaks building the project on a Mac at the command line.

Building the same project in VS for Windows (paired to a Mac) works.

Steps to Reproduce

  1. dotnet new ios -n someName on a Mac
  2. Create a nuget.config file for the created project with a Windows path like C:\n
    for example:
<configuration>
  <config>
    <add key="globalPackagesFolder" value="C:\n" />
  </config>
</configuration>
  1. dotnet build
  2. or, just download and run the provided example project

Expected Behavior

The app builds with no errors.

Actual Behavior

A Failed to create CoreCLR, HRESULT: 0x80070057 error, along with a message about setting the PublishTrimmed property to false, which is disallowed in a.NET for iOS app anyway

Environment

Version information

.NET SDK version 8.0.302
Workload info: ios 17.2.8053/8.0.100 SDK 8.0.300

Example Project (If Possible)

https://github.com/brunck/reproductions/tree/master/NuGetConfigBuildError

Copied from original issue xamarin/xamarin-macios#20800

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Wed, 03 Jul 2024 19:37:43 GMT

This looks like a bug in .NET:

$ mkdir rootdir
$ cd rootdir
$ dotnet new console
[...]
$ dotnet publish /p:PublishDir=C:
[...]
$ dotnet exec C:/rootdir.dll
Failed to create CoreCLR, HRESULT: 0x80070057

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Wed, 03 Jul 2024 19:40:38 GMT

Looks like variations of #3163 and #75387

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 3, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jul 3, 2024
Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

@vitek-karas vitek-karas added the os-ios Apple iOS label Jul 8, 2024
@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 9, 2024
@vitek-karas
Copy link
Member

This is weird to me:

Failed to create CoreCLR, HRESULT: 0x80070057

That is trying to run the app - I would not expect an ios app to run on CoreCLR, we could produce a better error, but functionally this is simply not supported.

But the issue states that it fails during build, which would not be this failure. What does the build failure look like?

@brunck
Copy link

brunck commented Jul 15, 2024

  Determining projects to restore...
  All projects are up-to-date for restore.
  Detected signing identity:
          
    Bundle Id: com.companyname.TestiOSApp
    App Id: com.companyname.TestiOSApp
  TestiOSApp -> /Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/bin/Debug/net8.0-ios/iossimulator-x64/TestiOSApp.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.
  Failed to create CoreCLR, HRESULT: 0x80070057
/Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/C:/n/microsoft.net.illink.tasks/8.0.6/build/Microsoft.NET.ILLink.targets(134,5)
: error MSB6006: "dotnet" exited with code 137. [/Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/TestiOSApp.csproj]            /Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/C:/n/microsoft.net.illink.tasks/8.0.6/build/Microsoft.NET.ILLink.targets(87,5):
 error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [/Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/TestiOSApp.csproj]                                                                          
Build FAILED.

/Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/C:/n/microsoft.net.illink.tasks/8.0.6/build/Microsoft.NET.ILLink.targets(134,5)
: error MSB6006: "dotnet" exited with code 137. [/Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/TestiOSApp.csproj]            /Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/C:/n/microsoft.net.illink.tasks/8.0.6/build/Microsoft.NET.ILLink.targets(87,5):
 error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [/Users/x/Documents/SourceCode/reproductions/NuGetConfigBuildError/TestiOSApp.csproj]                                                                              0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:04.20

Workload updates are available. Run `dotnet workload list` for more information.

@vitek-karas
Copy link
Member

It fails to launch illink.

@vitek-karas vitek-karas added area-Tools-ILLink .NET linker development as well as trimming analyzers os-mac-os-x macOS aka OSX and removed area-Host os-ios Apple iOS labels Jul 15, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@agocke agocke added this to the 10.0.0 milestone Jul 29, 2024
@agocke agocke removed the untriaged New issue has not been triaged by the area owner label Jul 29, 2024
@rolfbjarne
Copy link
Member Author

Here's a simpler repro: #104402 (comment)

@vitek-karas
Copy link
Member

The command which fails looks something like

dotnet ~/repro/app/C:/n/nugetcatchpath/illink.dll

The problem is that this leads to ~/repro/app/C:/n/nugetcatchpath/illink.dll being part of TPA. But TPA is a string which stores a list of file paths which are delimited by the OS's path separator, which is : on mac. So the path is seen as two by the runtime:

~/repro/app/C
/n/nugetcatchpath/illink.dll

Populating the internal TPA cache with this will fail because neither points to an existing file.

The short version of this bug is that running a .NET app in a path which has ':' in it somewhere fails.

@vitek-karas vitek-karas changed the title Building a dotnet new iOS app on the command line on a Mac fails with a Windows path in the nuget.config file Failed to create CoreCLR if an app has ':' (colon) in the path on Mac Aug 8, 2024
@vitek-karas vitek-karas added area-Host and removed area-Tools-ILLink .NET linker development as well as trimming analyzers labels Aug 8, 2024
Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

@am11
Copy link
Member

am11 commented Aug 25, 2024

Related to this, dotnet-publish fails with semicolon as well.

$ dotnet new console -n 't;e;s;t'
$ cd 't;e;s;t'

$ dotnet publish -o dist
MSBUILD : error MSB1006: Property is not valid.
Switch: e

For switch syntax, type "MSBuild -help"

$ dotnet publish -p:PublishDir="$(pwd)/dist"                
The "HasTrailingSlash" function only accepts a scalar value, but its argument "$(ClickOncePublishDir)" evaluates to "/Users/adeel/projects/t;e;s;t/dist" which is not a scalar value.  /Users/adeel/.dotnet9/sdk/9.0.100-rc.1.24414.26/Microsoft.Common.CurrentVersion.targets
MSBUILD : error MSB1006: Property is not valid.
Switch: e

For switch syntax, type "MSBuild -help"

# without publishdir or -o / --output, it works
$ dotnet publish
Restore complete (0,3s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  t;e;s;t succeeded (0,3s) → bin/Release/net9.0/publish/

Build succeeded in 0,7s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

7 participants