question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not load file or assembly Microsoft.DotNet.PlatformAbstractions under `dotnet tye`

See original GitHub issue

I see the following in logs for an azure-pipeline job for a dotnet core 3.1 application. These lines appear in the tye step of this pipeline.

Regardless of this error, the versions still seem to be updated correctly, for both the pipeline, dotnet assembly and node script. As such I post this here for informative purposes only.

2020-04-13T05:26:25.9406642Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
2020-04-13T05:26:25.9408785Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
2020-04-13T05:26:25.9410785Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:  ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKey***=adb9793829ddae60'. The system cannot find the file specified.
2020-04-13T05:26:25.9412046Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018: 
2020-04-13T05:26:25.9413899Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018: File name: 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKey***=adb9793829ddae60'
2020-04-13T05:26:25.9415112Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at Nerdbank.GitVersioning.GitLoaderContext.GetNativeLibraryDirectory()
2020-04-13T05:26:25.9416177Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at Nerdbank.GitVersioning.GitLoaderContext.LoadUnmanagedDll(String unmanagedDllName)
2020-04-13T05:26:25.9417326Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext)
2020-04-13T05:26:25.9418454Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
2020-04-13T05:26:25.9419623Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
2020-04-13T05:26:25.9420629Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor()
2020-04-13T05:26:25.9421673Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018: 
2020-04-13T05:26:25.9422629Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018: 
2020-04-13T05:26:25.9423869Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    --- End of inner exception stack trace ---
2020-04-13T05:26:25.9424971Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_opts(Int32 option, UInt32 level, String path)
2020-04-13T05:26:25.9426094Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.git_libgit2_opts_set_search_path(ConfigurationLevel level, String path)
2020-04-13T05:26:25.9427226Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths(ConfigurationLevel level, String[] paths)
2020-04-13T05:26:25.9428371Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo(String pathUnderGitRepo, Boolean useDefaultConfigSearchPaths)
2020-04-13T05:26:25.9429732Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot)
2020-04-13T05:26:25.9430984Z /home/vsts/.nuget/packages/nerdbank.gitversioning/3.1.74/build/Nerdbank.GitVersioning.targets(71,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner()
2020-04-13T05:26:25.9431677Z     0 Warning(s)
2020-04-13T05:26:25.9432033Z     1 Error(s)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
eerhardtcommented, Apr 28, 2020

I am working on removing the Microsoft.DotNet.PlatformAbstractions library. Before dotnet/sdk#11076, this library was implicitly loadable from MSBuild running on .NET Core. This was because the assembly was shipping in the dotnet\sdk\<version> directory. After dotnet/sdk#11076, the .NET 5.0 SDK no longer ships PlatformAbstractions with it.

So if your task relies on PlatformAbstractions, you will need to package the assembly with your task assembly (just like any other 3rd party library).

Alternatively, an API to get the current machine’s RID was added to .NET 5 with RuntimeInformation.RuntimeIdentifier. However, it is only available on .NET 5, and not previous versions of .NET Core, nor on .NET Framework.

3reactions
yyjdeletecommented, Apr 28, 2020

@AArnott Get the same exception when try lastest daily builds of net5.0 sdk, and seems Microsoft.DotNet.PlatformAbstractions is already removed and no longer be an part of lastest daily builds of net5.0 sdk. https://github.com/dotnet/runtime/issues/3470 https://github.com/dotnet/sdk/pull/11076

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing Microsoft.DotNet.PlatformAbstractions ...
FileNotFoundException : Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken= ...
Read more >
Microsoft.DotNet.PlatformAbstractions package removed - . ...
Learn about the .NET 5 breaking change in core .NET libraries where the Microsoft.DotNet.PlatformAbstractions package has been removed.
Read more >
fixing Microsoft.DotNet.PlatformAbstractions not found on ...
so i decided to blog this in case i have to solve it again ;). System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft....
Read more >
Microsoft.DotNet.PlatformAbstractions 3.1.6
Provides API for dynamically loading assemblies into a .NET application. This package should be used by the host application which needs to load...
Read more >
Can't clean the solution with UE 5.0.3 from GitHub
For some reason clean doesn't work with bundled dotnet. Workaround for now: change path to dotnet ( File | Settings | Build, Execution,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found