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

Access denied for NuGet package source while build dotnet/cli 3.1.300 Tag #11795

Closed
normj opened this issue May 28, 2020 · 30 comments
Closed

Access denied for NuGet package source while build dotnet/cli 3.1.300 Tag #11795

normj opened this issue May 28, 2020 · 30 comments

Comments

@normj
Copy link
Contributor

normj commented May 28, 2020

I'm trying to build version 3.1.300 of the dotnet/cli repository but the build.sh fails during the restore process with the following error message:

/build/cli/artifacts/toolset/restore.proj : error : Unable to load the service index for source https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-core-setup-0c2e69ca/nuget/v3/index.json.
100 | /build/cli/artifacts/toolset/restore.proj : error : Unable to load the service index for source https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-corefx-059a4a19/nuget/v3/index.json.
101

When I try to go directly to the URL for the package source I get access denied:

{"$id":"1","innerException":null,"message":"TF400813: The user 'Windows Live ID\\[email protected]' is not authorized to access this resource.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000}

The https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-core-setup-0c2e69ca/nuget/v3/index.json package source is coming from the NuGet.config file here https://github.com/dotnet/cli/blob/v3.1.300/NuGet.config

Why are the package source requiring authentication and how are automation machines not running in the .NET team's build system supposed to be able to build the project if authentication is required.

@normj
Copy link
Contributor Author

normj commented Jun 2, 2020

Any chance I can get an update on this? This is blocking us rolling out the update at AWS.

@asbjornu
Copy link
Member

asbjornu commented Aug 2, 2020

I'm having this problem now as well. I'm trying to create a Homebrew formula for .NET Core (see #4600) and in order to do so, I have to be able to build .NET Core from source. With the required private NuGet package feeds, it currently seems impossible to build .NET Core from source. Is this intentional?

@asbjornu
Copy link
Member

asbjornu commented Aug 2, 2020

Seems like dotnet/cli@7c1fa3d#diff-a7c26590e27fcbb61c69ff2564beb1fa changed the feeds from darc-pub-dotnet-* to darc-int-dotnet-*, which I assume made them go from public to internal. As the change is made by @dotnet-bot, I can't think of any other reason for this change than an oversight and that this must be a bug.

Simply removing the internal feeds from NuGet.config just leads to a swath of other problems saying Source control information is not available - the generated source link is empty. I don't even know where to begin looking for the source of this problem, so some assistance would be helpful.

Trying to build a version from before dotnet/cli@7c1fa3d, such as v3.1.201, ends up printing an almost endless amount of the similar error message to the console:

Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/2160f577-8dc0-4c31-83d2-8d0e0da8208c/nuget/v3/flat2/runtime.native.system/index.json'.
  An error occurred while sending the request.
    Problem with the SSL CA cert (path? access rights?)

Finally failing and halting on the following error:

.dotnet/sdk/3.1.200-preview-014946/NuGet.targets(124,5): error : Too many open files [Microsoft.DotNet.Cli.sln]

Trying to access one of the faulty feeds ends up returning the following JSON-wrapped exception:

{
    "$id": "1",
    "innerException": null,
    "message": "Can't find the package 'runtime.native.system' in feed 'dotnet3.1'.",
    "typeName": "Microsoft.VisualStudio.Services.NuGet.WebApi.Exceptions.PackageNotFoundException, Microsoft.VisualStudio.Services.NuGet.WebApi",
    "typeKey": "PackageNotFoundException",
    "errorCode": 0,
    "eventId": 3000
}

So currently, it seems impossible to build any version of .NET Core from source unless you're hired by Microsoft and have access to their internal NuGet feeds. That's very, very unfortunate. A fix would be highly appreciated. 🙏

@dagood
Copy link
Member

dagood commented Aug 3, 2020

Seems like dotnet/cli@7c1fa3d#diff-a7c26590e27fcbb61c69ff2564beb1fa changed the feeds from darc-pub-dotnet-* to darc-int-dotnet-*, which I assume made them go from public to internal. As the change is made by @dotnet-bot, I can't think of any other reason for this change than an oversight and that this must be a bug.

This has to do with how 3.1 dependency update works... we decided to go with a simpler approach (in some respects) where every single dependency update is checked into the repo. This has an unfortunate chain of dependencies leading to the tooling checking in each internal NuGet feed required:

  1. Somewhat immutable facts:
    • In Azure DevOps, it's impossible to update a package in-place in a feed.
    • In servicing branches, we build packages with stable versions, yet want to build it multiple times and put them in nuget feeds.
  2. To work around the lack of in-place update, we generate a feed per build.
  3. The build-specific feed needs to be accessible to the the build, so we check it in.

The intent is that on release day, every single internal-only package is published to the public feeds. Your attempt to fix by removing the internal feeds from the nuget.config should have worked! (IMO it isn't documented well enough, we need to make this obvious.)

@mmitche has dotnet/arcade#5233 opened, to track having the build script automatically remove the internal feeds so you don't need to do this step manually.

dotnet/source-build actually relies on this exact fix working. For example, https://github.com/dotnet/source-build/tree/v3.1.106-SDK was an internal build that we can now build from source publicly. The dotnet/source-build infrastructure dynamically deletes internal feeds from each repo's NuGet.config before building it.

(For context: dotnet/source-build is how Fedora got its fully built from source 3.1.106 SDK. dotnet/source-build also handles building the .NET repos in the correct order and passing dependencies through, so it's more truly "from source" than just building from an individual repo's tag and letting it download Microsoft-built binaries. Note that it only maintains 3.1.1xx, not 3.1.2xx, so switching over might not work for everyone, but I would recommend it if you can.)


I'm not sure why that the nuget.config fixup didn't work in this case. Someone familiar with dotnet/sdk in particular (or the dotnet/arcade toolset) needs to look into that, and I think this issue tracks that adequately. @marcpopMSFT

@mmitche
Copy link
Member

mmitche commented Aug 3, 2020

There is another option:

  • NuGet has a recent change that allows for inaccessible feeds to not fail the restore. Because of how we specify package versions, this option (RestoreIgnoreFailedSources=true), should be safe to use. It looks like it's a tad buggy at the moment:

NuGet/Home#9765

The downside of SetupNuGetSources.ps1 is:

  • It alters local files in the enlistment
  • It's not currently integrated into build.ps1 (and not all places use the common build.ps1), so users would need to explicitly call it.

@marcpopMSFT
Copy link
Member

Alternatively, you may be able to remove the internal darc feeds from the NuGet config. @mmitche is going to look for any documentation arcade might have on this process.

A quick summary is that when we identify a security vulnerability we need to fix, we make the fix and produce builds for testing the fix internally. This limits the risk of exposure as we don't want to be public with the specific security fix until we have the fix signed off and ready for consumption. Arcade doesn't allow us to maintain parallel public and internal channels for flowing code so our public builds during these times can end up in an odd state. We'll try to get some documentation updated to help unblock you for how to build as typically we're only in this state for a short period of time as we also want to get the security fixes out as quickly as we can.

@dagood
Copy link
Member

dagood commented Aug 3, 2020

Alternatively, you may be able to remove the internal darc feeds from the NuGet config.

This was tried and and it failed, see above--in particular #11795 (comment). Can you look into it (or otherwise triage this issue)?

@mmitche
Copy link
Member

mmitche commented Aug 3, 2020

Ahh I missed that line there. Trying locally on my machine.

@mmitche
Copy link
Member

mmitche commented Aug 3, 2020

@asbjornu When you get the errors after removing the darc-int feeds...are you building from the command line, VS, etc. I eliminated them without any issues and built on the command line.

In fact, those two (v3.1.300) feeds no longer contain any packages at all. Every night we run through every one of our feeds and eliminate those packages that also exist at the same version on nuget.org. This keeps nuget.org as the "source of truth".

@dagood
Copy link
Member

dagood commented Aug 3, 2020

We saw the same issue in source-build (error : Source control information is not available - the generated source link is empty.) when someone tried to build from the zip that GitHub generates. That zip doesn't contain a .git dir, which SourceLink unfortunately requires. We're tracking it in dotnet/source-build#1646 and haven't had a chance to follow up on it yet. It would be great to fix in the dotnet/arcade tooling.

@asbjornu where did you get the source code from?

@asbjornu
Copy link
Member

asbjornu commented Aug 3, 2020

I was building in iTerm2, running./build.sh --configuration Release on a downloaded .tar.gz, as that's the preferable way to build from source in Homebrew. It's possible to build from a cloned Git repository, but that means the formula becomes "head only" and has to be installed with the --HEAD argument. I'm not yet sure how it will affect dependent formulae, but it doesn't sound like the recommended path to take.

@dagood
Copy link
Member

dagood commented Aug 3, 2020

downloaded .tar.gz, as that's the preferable way to build from source in Homebrew.

Thanks for this info, might be useful to know to justify some things.

I'm not yet sure how it will affect dependent formulae, but [using a cloned Git repo] doesn't sound like the recommended path to take.

For now, having .git is the only way it will work to run a "normal" build. You could work around it by disabling SourceLink and related things that depend on the Git data:

./build.sh /p:EnableSourceLink=false /p:DeterministicSourcePaths=false /p:EnableSourceControlManagerQueries=false

(At least, that works for me on a downloaded 3.1.302 source zip with the nuget.config modification. (I also got rid of the extra runtime installs in eng/restore-toolset.sh to work around those not being found, but that's tracked by #1850.))

@asbjornu
Copy link
Member

asbjornu commented Aug 4, 2020

Thanks for that @dagood. With your instructions, I've now managed to build sdk v3.1.302 locally after removing the internal NuGet feeds. I'm unable to get it to work in Homebrew, though, as it fails with the following exception:

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.ComponentModel.Win32Exception (13): Permission denied
   at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
   at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Unhandled exception. System.ComponentModel.Win32Exception (13): Permission denied
   at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
   at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
Build failed (exit code '134').

Building cli v3.1.302 with Homebrew seems to work a bit better, but it also fails, most likely due to #1850?

 Retrying 'FindPackagesByIdAsync' for source 'https://dotnetmyget.blob.core.windows.net/artifacts/nuget-build/nuget/v3/flatcontainer/microsoft.build.tasks.git/index.json'.
  An error occurred while sending the request.
    Couldn't connect to server
/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/.dotnet/sdk/3.1.200-preview-014946/NuGet.targets(124,5): error : Failed to retrieve information about 'System.Linq.Queryable' from remote source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/89836ee7-f4d9-4429-90a9-9e9005780b57/nuget/v3/flat2/system.linq.queryable/index.json'. [/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/Microsoft.DotNet.Cli.sln]
/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/.dotnet/sdk/3.1.200-preview-014946/NuGet.targets(124,5): error :   An error occurred while sending the request. [/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/Microsoft.DotNet.Cli.sln]
/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/.dotnet/sdk/3.1.200-preview-014946/NuGet.targets(124,5): error :   Couldn't connect to server [/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/Microsoft.DotNet.Cli.sln]

Build FAILED.

/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/.dotnet/sdk/3.1.200-preview-014946/NuGet.targets(124,5): error : Failed to retrieve information about 'System.Linq.Queryable' from remote source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/89836ee7-f4d9-4429-90a9-9e9005780b57/nuget/v3/flat2/system.linq.queryable/index.json'. [/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/Microsoft.DotNet.Cli.sln]
/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/.dotnet/sdk/3.1.200-preview-014946/NuGet.targets(124,5): error :   An error occurred while sending the request. [/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/Microsoft.DotNet.Cli.sln]
/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/.dotnet/sdk/3.1.200-preview-014946/NuGet.targets(124,5): error :   Couldn't connect to server [/private/tmp/dotnet-20200804-7180-15g7er6/cli-3.1.302/Microsoft.DotNet.Cli.sln]
    0 Warning(s)
    1 Error(s)

I was able to get much further with source-build v3.1.106-SDK, but due to dotnet/source-build#1646, we will end up with a "head only" formula, which should be avoided.

Ideas?

@dagood
Copy link
Member

dagood commented Aug 4, 2020

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.ComponentModel.Win32Exception (13): Permission denied
at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)

This is an MSBuild bug with niceness level I happened to hear about at dotnet/core#4719. I'm not sure what a simple workaround is here, but you may need to adjust niceness level up or down to match what MSBuild expects.

Building cli v3.1.302 with Homebrew seems to work a bit better, but it also fails, most likely due to #1850?

Seems unrelated to me, worth opening an issue about.

I was able to get much further with source-build v3.1.106-SDK, but due to dotnet/source-build#1646, we will end up with a "head only" formula, which should be avoided.

This seems like a really weird limitation of that build system to me. Why is starting a build with .git data included tied to --HEAD: Fetch HEAD version instead of stable version.? This is not at all the intent or what we need. Is there really no way to fetch a stable version with git data? How is homebrew getting the sources anyway?

@normj
Copy link
Contributor Author

normj commented Aug 4, 2020

What I did to get around the issue was remove the internal darc feeds and the build worked fine for me afterwards. I would really like a better fix then me making changes to the repo before doing a build.

@dagood
Copy link
Member

dagood commented Aug 4, 2020

I would really like a better fix then me making changes to the repo before doing a build.

For sure. To reiterate, that's tracked by dotnet/arcade#5233 (or an offshoot issue from there in the future).

@asbjornu
Copy link
Member

asbjornu commented Aug 4, 2020

To me, it feels like using the dotnet/source-build repository for source builds is the best option. The only thing that seems to be missing is dotnet/source-build#1646 (comment).

Building the sdk and cli repositories require too much source modifications and other local "hacks" in order to get the build to work and seems to go against the goals of the repositories. Since the goal of the source-build repository is to provide source builds, that feels like the absolute best option to me.

@asbjornu
Copy link
Member

asbjornu commented Aug 5, 2020

Thanks to dotnet/source-build#1695 I'm now able to start the build from the provided .tar.gz file, but I'm still unable to build the entire thing to completion. This is the problem I'm now facing:

  Error: Could not load file or assembly 'Microsoft.AspNetCore.Http.Features, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
   (0x80070002)
  Error compiling /private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/bin/Microsoft.AspNetCore.Antiforgery/Release/netcoreapp3.1/Microsoft.AspNetCore.Antiforgery.dll: Could not find or load a specific file. (0x80131621)
  Error: compilation failed for "/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/bin/Microsoft.AspNetCore.Antiforgery/Release/netcoreapp3.1/Microsoft.AspNetCore.Antiforgery.dll" (0x80131621)
  Warning: Error enumerating files under /private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/obj/Microsoft.AspNetCore.App.Runtime/Release/netcoreapp3.1/osx-x64/platformAssemblies/.
/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj(376,5): error MSB3073: The command ""/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/obj/Microsoft.AspNetCore.App.Runtime/Release/netcoreapp3.1/osx-x64/crossgen/crossgen" -nologo -readytorun -in "/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/bin/Microsoft.AspNetCore.Antiforgery/Release/netcoreapp3.1/Microsoft.AspNetCore.Antiforgery.dll" -out "/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/bin/Microsoft.AspNetCore.App.Runtime/Release/netcoreapp3.1/osx-x64/Microsoft.AspNetCore.Antiforgery.dll" -jitpath "/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/packages/restored/microsoft.netcore.app.runtime.osx-x64/3.1.6/runtimes/osx-x64/native/libclrjit.dylib" "@/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/obj/Microsoft.AspNetCore.App.Runtime/Release/netcoreapp3.1/osx-x64/crossgen/PlatformAssembliesPaths.rsp"" exited with code 33.
##vso[task.logissue type=error;sourcepath=/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj;linenumber=376;columnnumber=5;code=MSB3073;]The command ""/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/obj/Microsoft.AspNetCore.App.Runtime/Release/netcoreapp3.1/osx-x64/crossgen/crossgen" -nologo -readytorun -in "/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/bin/Microsoft.AspNetCore.Antiforgery/Release/netcoreapp3.1/Microsoft.AspNetCore.Antiforgery.dll" -out "/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/bin/Microsoft.AspNetCore.App.Runtime/Release/netcoreapp3.1/osx-x64/Microsoft.AspNetCore.Antiforgery.dll" -jitpath "/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/packages/restored/microsoft.netcore.app.runtime.osx-x64/3.1.6/runtimes/osx-x64/native/libclrjit.dylib" "@/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/obj/Microsoft.AspNetCore.App.Runtime/Release/netcoreapp3.1/osx-x64/crossgen/PlatformAssembliesPaths.rsp"" exited with code 33.

Build FAILED.

It looks quite suspicious that version3.1.0.0 of Microsoft.AspNetCore.Http.Features is being referenced, as I believe 3.1.6.0 should be the version that corresponds to the provided .tar.gz file. There was a problem with stale references acknowledged in dotnet/aspnetcore#18334, but that should be fixed so I'm not sure why this is occurring or what to do about it.

Before I file an issue in the massively overwhelmed AspNetCore repository, do you have any ideas or input, @dagood?

@dagood
Copy link
Member

dagood commented Aug 6, 2020

This can have a variety of causes and we've run into (and fixed) a few in the past caused by dependency flow and source-build tweaks. That 3.1.0.0 might be fine and intended to discover a 3.1.6.0 DLL that's just not present. You could try using ilspy, dnspy or a similar tool on the DLL that failed to load and DLLs in the dirs being referenced to try to figure out the state of the build, but that's only the first step.

@asbjornu can you file an issue in dotnet/source-build? I suspect this is something about our infra. The macOS CI build is working in source-build (a smoke-test fails causing overall failure, but the build is ok), so there's probably some difference caused by configuration/env we'll need to figure out.
Also, the log barely scratches the surface of info available--can you include the binlog?

/private/tmp/dotnet-20200805-31137-10zr0wh/source-build-49195585d0de06e9a06b8fb005c460035363b2af/artifacts/src/aspnetcore.62c098bc170f50feca15916e81cb7f321ffc52ff/artifacts/log/Release/Build.binlog

Check out https://aka.ms/binlog first for the caveats (env is included).

@asbjornu
Copy link
Member

asbjornu commented Aug 8, 2020

After some progress in Homebrew/homebrew-core#53092 (comment), I'm now able to successfully build with the following Homebrew formula. The missing part is installing the built tarball. I hope to get that resolved with the help of the Homebrew team over the next few days.

The only question I'm left with here is: What version should we give the formula? Is the inferred version from the Git tag (3.1.106) okay, or is version 3.1.6 more appropriate? Since the formula is for both the SDK and the runtime, I'm not sure which version number takes precedence.

@dagood
Copy link
Member

dagood commented Aug 9, 2020

Since the formula is for both the SDK and the runtime, I'm not sure which version number takes precedence.

Using the SDK version is correct:

  • There might be a new version of the SDK released without a new runtime version
  • Multiple versions of the SDK use the same version of the runtimes (e.g. 3.1.106 and 3.1.302 both use 3.1.6)

We have some info about packaging recommendations at https://docs.microsoft.com/en-us/dotnet/core/distribution-packaging, but it actually gets this specific piece of info wrong so I've filed dotnet/docs#19921 to fix it.

@asbjornu
Copy link
Member

Thanks, @dagood. SDK version it is. I now have an almost working formula. The outstanding issues are related to .NET's environment requirements as per Homebrew/homebrew-core#53092 (comment):

  1. The file /etc/dotnet/install_location needs to be created containing the path to the lib directory.
  2. The environment variable DOTNET_ROOT must exist and point to the same lib directory path.
  3. Dependencies such as icu4c needs to be made available to .NET through the LD_LIBRARY_PATH environment variable, for instance.

These requirements make finalizing the installation very difficult. Point 1 is impossible to do in a Homebrew formula since Homebrew doesn't require (or even ask for) sudo while writing to /etc requires sudo. Point 2 and 3 also seems impossible since a formula can't declare environment variables.

What we would have to do in Homebrew is write detailed instructions on what a user needs to do to create the /etc/dotnet/install_location file and required environment variables.

What's worse is that even with the files and enviornment variables in place, the dotnet executable still fails with the error Couldn't find a valid ICU package installed on the system:

LD_LIBRARY_PATH="/usr/local/lib" dotnet --info
Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
   at System.Globalization.GlobalizationMode..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.CultureInfo..cctor()
   at System.Version.TryParseComponent(System.ReadOnlySpan`1<Char>, System.String, Boolean, Int32 ByRef)
   at System.Version.ParseVersion(System.ReadOnlySpan`1<Char>, Boolean)
   at System.Version.TryParse(System.String, System.Version ByRef)
   at Microsoft.DotNet.PlatformAbstractions.Native.PlatformApis.GetDarwinVersion()
   at Microsoft.DotNet.PlatformAbstractions.Native.PlatformApis.GetOSVersion()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
   at Microsoft.DotNet.Cli.MulticoreJitProfilePathCalculator.CalculateProfileRootPath()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.StartCliProfileOptimization()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.TryActivateMulticoreJit()
   at Microsoft.DotNet.Cli.Program.Main(System.String[])
Abort trap: 6

So before figuring out what to write in a caveats section of the formula, I would highly appreciate some help getting dotnet to execute successfully locally. I've declared icu4c as a runtime requirement for the dotnet formula and it is installed in /usr/local/Cellar/icu4c/67.1/lib/. The installed .dylib files are not symblinked from /usr/local/lib, though running the following also fails:

LD_LIBRARY_PATH="/usr/local/Cellar/icu4c/67.1/lib/" dotnet --info

If we can get around this ICU problem, it would be interesting to see whether the other requirements are actual requirements or just recommendations.

@devlead
Copy link
Contributor

devlead commented Aug 17, 2020

Seen some build servers have an executable bash script in path named dotnet that sets up needed environment variables for that session only and passes along all arguments to "native" binary. Could that be a possibility?

@dagood
Copy link
Member

dagood commented Aug 17, 2020

These requirements make finalizing the installation very difficult. Point 1 is impossible to do in a Homebrew formula since Homebrew doesn't require (or even ask for) sudo while writing to /etc requires sudo. Point 2 and 3 also seems impossible since a formula can't declare environment variables.

Some more detail about these locations: https://github.com/dotnet/designs/blob/92af9e911006df64cfe75714121584e1b2d21ee9/accepted/2020/install-locations.md

It sounds like you aren't making what would typically be considered a distro package, so yeah, don't worry about that. With these limitations it sounds like what you need is a per-user install. Some more detail here:

https://github.com/dotnet/source-build/blob/release/3.1/Documentation/packaging-installation.md

(Points to https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#manual-install for details on per-user install.)

What's worse is that even with the files and enviornment variables in place, the dotnet executable still fails with the error Couldn't find a valid ICU package installed on the system:

This is a known issue with the dotnet/coreclr repo on new versions of CMake, which has had a fix committed for the next release. (I linked you this earlier and I thought it had something to do with Big Sur, but it's just CMake.) More details and getting the fix in a dotnet/source-build release is tracked by dotnet/source-build#1685. dotnet/coreclr#28066 looks like a simple enough change to add a patch for, for now.

This is getting fairly long and off the original topic, I'd recommend filing these types of issues in dotnet/source-build.

@dagood
Copy link
Member

dagood commented Aug 17, 2020

Seen some build servers have an executable bash script in path named dotnet that sets up needed environment variables for that session only and passes along all arguments to "native" binary. Could that be a possibility?

It looks like this is actually pretty common in Homebrew with write_env_script and env_script_all_files if I'm reading it right.

@asbjornu
Copy link
Member

Thanks for the tip on write_env_script. That may indeed work! 👍 But before dotnet/source-build#1685 is resolved, it's hard to tell. Is it possible to have that fast-tracked somehow, @dagood?

@dagood
Copy link
Member

dagood commented Aug 18, 2020

But before dotnet/source-build#1685 is resolved, it's hard to tell. Is it possible to have that fast-tracked somehow, @dagood?

Replied at dotnet/source-build#1685 (comment).

@asbjornu
Copy link
Member

With Homebrew/homebrew-core#60929 merged, this can be considered fixed for me at least.

@kaangms
Copy link

kaangms commented Nov 20, 2022

Open Mac Settings

Screenshot 2022-11-21 at 01 15 44

enable vs code and vs studio

Screenshot 2022-11-21 at 01 17 58

And For Terminal

1- cd /Users/your_user_name/.local/share/
2-open . (open with Finder)
3-Nuget select and right click
4-click get info
a-open the lock
b-change Read and Write
c-apply to enclosed item
Screenshot 2022-11-21 at 01 25 04

@marcpopMSFT
Copy link
Member

old issue about building 3.1.300. Closing. Please file a new issue if this still affects 7.0.100.

@marcpopMSFT marcpopMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2022
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

7 participants