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

Having trouble with roll-forward #42478

Closed
richlander opened this issue Sep 18, 2020 · 19 comments
Closed

Having trouble with roll-forward #42478

richlander opened this issue Sep 18, 2020 · 19 comments
Assignees
Milestone

Comments

@richlander
Copy link
Member

I am having trouble configuring roll-forward. I'm not sure what I'm missing.

I have no .NET installed globally on this machine.

pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ dotnet
-bash: dotnet: command not found

I am working out of a clone of the dotnet/iot repo and using the toolset that it downloads/uses. It works great for the SDK. .NET 5.0 is much faster than I recall previous versions being, but that's separate. I hope it's true.

pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ export | grep DOTNET
declare -x DOTNET
declare -x DOTNET_ROLL_FORWARD="LatestMajor"
declare -x DOTNET_ROLL_FORWARD_TO_PRERELEASE="1"
declare -x DOTNET_ROOT="/home/pi/iot/.dotnet"
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ export | grep COREHOST
declare -x COREHOST_TRACE="1"
declare -x COREHOST_TRACE_VERBOSITY="1"
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ whoami
pi
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ ~/iot/.dotnet/dotnet --version
5.0.100-preview.6.20310.4
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ ./bin/Debug/netcoreapp3.1/linux-arm/ShiftRegister-driver
Failed to create CoreCLR, HRESULT: 0x80070057
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ cat ./bin/Debug/netcoreapp3.1/linux-arm/ShiftRegister-driver.runtimeconfig.json
{
  "runtimeOptions": {
    "tfm": "netcoreapp3.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "3.1.0"
    }
  }
}pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $

I then installed RC2 ...

pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ export DOTNET_ROOT=/home/pi/dotnet
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ ls /home/pi/dotnet
dotnet  host  LICENSE.txt  packs  sdk  shared  templates  ThirdPartyNotices.txt
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ /home/pi/dotnet/dotnet --version
5.0.100-rc.1.20367.2
pi@raspberrypi:~/iot/src/devices/ShiftRegister/samples $ ./bin/Debug/netcoreapp3.1/linux-arm/ShiftRegister-driver
Failed to create CoreCLR, HRESULT: 0x80070057
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Meta untriaged New issue has not been triaged by the area owner labels Sep 18, 2020
@ghost
Copy link

ghost commented Sep 19, 2020

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

@jkotas jkotas removed the area-Meta label Sep 19, 2020
@jkotas
Copy link
Member

jkotas commented Sep 19, 2020

I then installed RC2 ...
5.0.100-rc.1.20367.2

RC1 or RC2? (I have tried the steps with hello world on latest RC2 and it worked for me.)

@richlander
Copy link
Member Author

richlander commented Sep 22, 2020

Here is more info ...

pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ export | grep DOTNET                                                                                                          │
declare -x DOTNET_ROLL_FORWARD="LatestMajor"                                                                                                                                                            │
declare -x DOTNET_ROOT="/home/pi/dotnet3"                                                                                                                                                               │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ export | grep CORE                                                                                                            │
declare -x COREHOST_TRACE="1"                                                                                                                                                                           │
declare -x COREHOST_TRACEFILE="trace.txt"                                                                                                                                                               │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ cat GpioOutputSegment-driver.csproj                                                                                           │
<Project Sdk="Microsoft.NET.Sdk">                                                                                                                                                                       │

  <PropertyGroup>                                                                                                                                                                                       │
    <OutputType>Exe</OutputType>                                                                                                                                                                        │
    <TargetFramework>netcoreapp3.1</TargetFramework>                                                                                                                                                    │
    <Nullable>enable</Nullable>                                                                                                                                                                         │
  </PropertyGroup>                                                                                                                                                                                      │

  <ItemGroup>                                                                                                                                                                                           │
     <ProjectReference Include="../Multiplexing.csproj" />                                                                                                                                              │
  </ItemGroup>                                                                                                                                                                                          │

</Project>                                                                                                                                                                                              │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ whoami                                                                                                                        │
pi                                                                                                                                                                                                      │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ~/dotnet3/dotnet --version                                                                                                    │
A compatible installed .NET Core SDK for global.json version [5.0.100-preview.6.20310.4] from [/home/pi/iot/global.json] was not found                                                                  │
Install the [5.0.100-preview.6.20310.4] .NET Core SDK or update [/home/pi/iot/global.json] with an installed .NET Core SDK:                                                                             │
  3.1.403 [/home/pi/dotnet3/sdk]                                                                                                                                                                        │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ~/dotnet/dotnet --version                                                                                                     │
5.0.100-rc.2.20471.15                                                                                                                                                                                   │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ./bin/Debug/netcoreapp3.1/GpioOutputSegment-driver                                                                            │
Hello World                                                                                                                                                                                             │
^C                                                                                                                                                                                                      │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ mv trace.txt trace3.txt                                                                                                       │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ export DOTNET_ROOT=/home/pi/dotnet                                                                                            │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ls $DOTNET_ROOT
dotnet  host  LICENSE.txt  packs  sdk  shared  templates  ThirdPartyNotices.txt                                                                                                                         │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ./bin/Debug/netcoreapp3.1/GpioOutputSegment-driver                                                                            │
Failed to create CoreCLR, HRESULT: 0x80070057                                                                                                                                                           │
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ mv trace.txt trace5.txt

trace3.txt
trace5.txt

Built from this commit: richlander/iot@124131f

@richlander
Copy link
Member Author

This problem seems to arrive with Preview 6.

pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ export DOTNET_ROOT=/home/pi/dotnet5p5                                                                                        
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ./bin/Debug/netcoreapp3.1/GpioOutputSegment-driver                                                                           
Hello World                                                                                                                                                                                            
^C                                                                                                                                                                                                     
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ export DOTNET_ROOT=/home/pi/dotnet5p6                                                                                        
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ./bin/Debug/netcoreapp3.1/GpioOutputSegment-driver                                                                           
Failed to create CoreCLR, HRESULT: 0x80070057                                                                                                                                                          
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ~/dotnet5p6/dotnet --version                                                                                                 
5.0.100-preview.6.20318.15                                                                                                                                                                             
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ ~/dotnet5p5/dotnet --version                                                                                                 
Could not execute because the application was not found or a compatible .NET SDK is not installed.                                                                                                     
Possible reasons for this include:                                                                                                                                                                     
  * You intended to execute a .NET program:                                                                                                                                                            
      The application '--version' does not exist.                                                                                                                                                      
  * You intended to execute a .NET SDK command:                                                                                                                                                        
      A compatible installed .NET SDK for global.json version [5.0.100-preview.6.20310.4] from [/home/pi/iot/global.json] was not found.                                                               
      Install the [5.0.100-preview.6.20310.4] .NET SDK or update [/home/pi/iot/global.json] with an installed .NET SDK:                                                                                
        5.0.100-preview.5.20279.10 [/home/pi/dotnet5p5/sdk]                                                                                                                                            
pi@raspberrypi:~/iot/src/devices/Common/Iot/Device/Multiplexing/samples $ cd                                                                                                                           
pi@raspberrypi:~ $ ~/dotnet5p5/dotnet --version                                                                                                                                                        
5.0.100-preview.5.20279.10

@richlander
Copy link
Member Author

Here is an example app that is causing me trouble.

bin.zip

@richlander
Copy link
Member Author

I just built the led-blink project inside and outside the repo. Outside, it works. Inside, it does not. The two builds produce different results.

See:

pi@raspberrypi:~/iot/samples/led-blink $ ls bin/Debug/netcoreapp3.1/                                                                                                                                   
Iot.Device.Bindings.dll  led-blink.dll                     led-blink.xml                     System.Device.Gpio.xml     Windows.Devices.DevicesLowLevelContract.winmd                                  
Iot.Device.Bindings.xml  led-blink.pdb                     Microsoft.Win32.SystemEvents.dll  System.Drawing.Common.dll  Windows.Foundation.FoundationContract.winmd                                    
led-blink                led-blink.runtimeconfig.dev.json  runtimes                          System.IO.Ports.dll        Windows.Foundation.UniversalApiContract.winmd                                  
led-blink.deps.json      led-blink.runtimeconfig.json      System.Device.Gpio.dll            UnitsNet.dll                                                                                              
pi@raspberrypi:~/iot/samples/led-blink $ ls ~/led-blink/bin/Debug/netcoreapp3.1/                                                                                                                       
led-blink  led-blink.deps.json  led-blink.dll  led-blink.pdb  led-blink.runtimeconfig.dev.json  led-blink.runtimeconfig.json  System.Device.Gpio.dll                                                   
pi@raspberrypi:~/iot/samples/led-blink $

The IoT msbuild assets are causing the build to be different and for WinRT assets to be included that don't otherwise exist. That leaves to believe that one of two things is happening:

  • The IoT build is doing something incorrect.
  • The host is getting tripped up on WinRT assets, and is producing a poor error message that should be improved.

The fact that Preview 5 works and Preview 6 doesn't seems very aligned with the timing of the WinRT breaking change.

@vitek-karas
Copy link
Member

Could you please share the built binaries for these two version of the app? That should help greatly with both repro and figuring out what's wrong.

@agocke agocke removed the untriaged New issue has not been triaged by the area owner label Sep 22, 2020
@agocke agocke added this to the 5.0.0 milestone Sep 22, 2020
@richlander
Copy link
Member Author

Good idea.

In the zip:

  • led-blink1 (the version that was at ~/led-blink)
  • led-blink2 (the version that was at ~iot/samples/led-blink)

led-blink.zip

@sbomer
Copy link
Member

sbomer commented Sep 22, 2020

We're tripping over a winmd that is passed as a native runtime asset - I think this is expected to fail from the runtime's point of view:

if (fileName.EndsWithCaseInsensitive(sNiDll) ||
fileName.EndsWithCaseInsensitive(sNiExe))
{
simpleName.Set(fileName, iSimpleNameStart, fileName.End() - 7);
isNativeImage = true;
}
else if (fileName.EndsWithCaseInsensitive(sDll) ||
fileName.EndsWithCaseInsensitive(sExe))
{
simpleName.Set(fileName, iSimpleNameStart, fileName.End() - 4);
}
else
{
// Invalid filename
GO_WITH_HRESULT(E_INVALIDARG);
}

The deps file of led-blink2 has:

      "Windows.Foundation.FoundationContract/3.0.0.0": {
        "runtime": {
          "Windows.Foundation.FoundationContract.winmd": {
            "assemblyVersion": "3.0.0.0",
            "fileVersion": "0.0.0.0"
          }
        }
      },
      "Windows.Devices.DevicesLowLevelContract/3.0.0.0": {
        "runtime": {
          "Windows.Devices.DevicesLowLevelContract.winmd": {
            "assemblyVersion": "3.0.0.0",
            "fileVersion": "0.0.0.0"
          }
        }
      },
      "Windows.Foundation.UniversalApiContract/7.0.0.0": {
        "runtime": {
          "Windows.Foundation.UniversalApiContract.winmd": {
            "assemblyVersion": "7.0.0.0",
            "fileVersion": "0.0.0.0"
          }
        }

@richlander
Copy link
Member Author

richlander commented Sep 22, 2020

Thanks @sbomer. That was my guess. Can we generate a better error message? If so, this is something that I'd like to consider for .NET 5.0. The current error message isn't actionable. This is account for the breaking change we made.

Separately, I think we should fix the dotnet/iot repo to "do the right thing". This project is one of the few that we have that is more like user code and could be used as a good example of best practice.

@AaronRobinsonMSFT
Copy link
Member

@jkoritzinsky What are your thoughts here? This is the roll forward policy kicking in for a 3.x application that is moving to 5.0 and using WinRT.

@sbomer
Copy link
Member

sbomer commented Sep 22, 2020

A better message would definitely be nice. Any of the errors created in this parsing code bubble up an HRESULT (E_INVALIDARG in a lot of cases), and the code in the host that prints the error doesn't know specifically what happened. I think we could improve the messages by using different error codes (or changing the host API), or printing the error from the runtime (but we'd have to make sure it doesn't get printed spuriously). Those feel a little risky to make for 5.0 at this point, IMO.

@AaronRobinsonMSFT
Copy link
Member

@richlander How common do we expect this to be? I thought major version roll-forward was an explicit opt-in (i.e. advanced scenario). If that is true I might consider this the price of doing business. My reason for saying that is my desire to avoid creating an error code and message that would be removed in the next release. Removed because this is only going to be impacting us for a relatively short period of time (i.e. the transition from 3.x to 5.0).

@richlander
Copy link
Member Author

There might be a misperception of what this situation represents. I agree that we should not do anything at this late point for the roll-forward scenario. I was thinking that this might show up for apps that use old NuGet packages. However, in thinking about it more, those should get caught by the build system and not the host.

That said, it was unfortunate that the trace didn't include the relevant error. That would be really nice to improve for 6.0. I assume that there are other error cases that are similarly not represented well in the trace.

@richlander
Copy link
Member Author

In terms of next steps, I assume the ball is in the dotnet/iot court to produce 5.0 assets. Might we start by including a net5.0 folder that doesn't include/support WinRT? Wouldn't that be pretty easy?

@AaronRobinsonMSFT
Copy link
Member

That said, it was unfortunate that the trace didn't include the relevant error. That would be really nice to improve for 6.0. I assume that there are other error cases that are similarly not represented well in the trace.

We are in agreement there. I had assumed the trace would include the name of any assembly it didn't find. If that isn't true an issue should be filed.

Might we start by including a net5.0 folder that doesn't include/support WinRT? Wouldn't that be pretty easy?

I think so. That is one of those questions I assume @jkoritzinsky immediately knows the answer.

@jkoritzinsky
Copy link
Member

That should be pretty easy to do while they wait to be unblocked by the Windows SDK team. (They're waiting on the Windows SDK team to strong-name their projection assembly.)

@richlander
Copy link
Member Author

richlander commented Sep 23, 2020

I added #42607 for this purpose.

I also added a tracking bug for dotnet/iot @ dotnet/iot#1193.

I can now close this one. Thanks everyone for the help!

@vitek-karas
Copy link
Member

@AaronRobinsonMSFT

I had assumed the trace would include the name of any assembly it didn't find. If that isn't true an issue should be filed.

My understanding is that the files are present so from host's point of view everything is OK - it's the runtime which refuses to load that file - this is essentially similar to having a corrupted assembly.

  • We could add knowledge to the host about file extensions and fail there when we detect anything but the file extensions supported by the runtime, but that feels wrong - ideally we should have only one place where the decision is made.
  • Runtime should generate a better error message - currently it relies on HRESULT alone - which is so not the right error reporting mechanism. I don't know what is the right mechanism - this is on the startup path, so throwing managed exceptions is probably out of question. We might need to invent a new mechanism for this ... unfortunately.

@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants