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.

Cli tool throws exception when dispatching and calling into "PlatformAbstractions" APIs

See original GitHub issue

Steps to reproduce

Repro repo here.

I have a tool that needs to load the target project, which targets the full .Net framework. As a result, I should dispatch the execution to the context of the target tfm (so net46 for example), because cli tools are always executed in the context of “netcoreapp”. Dispatching like this used to work perfectly in the preview2 tooling.

After the dispatch, if I try to use any of the “PlatformAbstractions” APIs the following exception occurs:

Unhandled Exception: System.IO.FileLoadException:
Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This line works when the context is “netcoreapp”, but it throws the exception after the dispatch to “net46”.

This is a major problem because “Command.CreateDotNet” fails as a result. My tool has a reference to “Microsoft.DotNet.Cli.Utils” v1.0.1 which I suspect is the root of the problem. Or maybe this is not how dispatching should be done in 1.0? (which I doubt, because when PlatformAbstractions is not involved, everything works).

I can’t find info or documentation at all about this. What’s going on?

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0)

Product Information:
 Version:            1.0.0
 Commit SHA-1 hash:  e53429feb4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0

For reference this is the tool I maintain.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:22 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
nphmullercommented, Mar 20, 2017

According to NuGet and project.assets.json the lowest version is indeed 1.0.3, but after building the project there’s definitely a reference to 1.0.1 (InformationVersion 1.0.1-beta). Same for Microsoft.Extensions.DependencyModel.

Here’s a minimum .csproj to reproduce: Just run dotnet restore && dotnet build

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="1.0.1" />
  </ItemGroup>
</Project>

It also reproduces with netcoreapp1.0, but it’s easier to see the output with net462.

Update: Did some more testing and <PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="1.0.3" /> downloads the 1.0.1.0 (1.0.1-beta) package. Same for Microsoft.Extensions.DependencyModel

1reaction
nphmullercommented, Nov 22, 2017

Just wrote a prototype and it indeed does not work yet. The project were I include a tool that only targets net46 throws a NU1202 error during package restore: Package tool-x 1.0.0 is not compatible with netcoreapp2.0.

I just found a newer version of DotnetToolDispatcher here: https://github.com/aspnet/Scaffolding/blob/8675aa97cd967d92bfa98e4008feb98853ca25e6/src/Shared/DotNetDispatcher/DotnetToolDispatcher.cs Note the method EnsureBindingRedirects. I’m slightly optimistic they fixed the binding redirect issue.

@livarcocc : Is there an official way to get to work what @mrahhal described (a cli tool that targets netfull)? Or at least an official NuGet package with DotnetToolDispatcher? Because currently the source is copied over manually an part of the tool project, which seems error prone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cli tool throws exception when dispatching and calling into ...
After the dispatch, if I try to use any of the "PlatformAbstractions" APIs the following exception occurs. This line works when the context...
Read more >
Returning the result from dispatch to a component throws " ...
I tried this but I received props.enrollStudent() is undefined error. props.enrollStudent(student, st_courseId) .then(() => { ...
Read more >
SAP Cloud SDK for Java – Release Notes
Fix an issue in the realm of HTTP destinations created through the SAP Cloud Platform Extension Factory where a DestinationAccessException occured.
Read more >
Aspnet Core Msdn | Microsoft Visual Studio - ID:5d0a9c659313d
NET Core is an ideal platform for building web APIs and RESTful apps on . ... Call first to catch exceptions // thrown...
Read more >
createAsyncThunk
When your payloadCreator returns a rejected promise (such as a thrown error in an async function), the thunk will dispatch a rejected action ......
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