aspnet / aspnet-docker

[Archived] ASP.NET Core Docker images for 1.x. Go to https://github.com/dotnet/dotnet-docker for 2.1 and up.
https://asp.net
719 stars 171 forks source link

The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found. #283

Closed SimonVuong closed 7 years ago

SimonVuong commented 7 years ago

Steps to reproduce the issue

We are building our aspnetcore app image in Jenkins and running the image in OpenShift.

  1. build the app
npm install
npm install @angular/cli
npm run build -prod
dotnet restore
dotnet publish --output ./app --configuration Release
cp Dockerfile ./app
cd app
  1. build the image

/tools/docker/docker-1.11.2/docker build --force-rm --no-cache --pull --rm=true -t $DOCKER_LOCATION:latest .

  1. run the image in OpenShift with the following Dockerfile
FROM microsoft/aspnetcore:1.1
RUN ls
WORKDIR /app
COPY . .
RUN cat pic.runtimeconfig.json
RUN cat pic.deps.json
EXPOSE 8080
ENTRYPOINT ["dotnet", "pic.dll"]

Expected behavior

image runs successfully

Actual behavior

image fails to run with error...

It was not possible to find any compatible framework version The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found. -- Check application dependencies and target a framework version installed at: / -- Alternatively, install the framework version '1.1.0'.

Additional information (e.g. issue happens only occasionally)

Output of dotnet --info in Jenkins

.NET Command Line Tools (1.0.1)

Product Information:
 Version:            1.0.1
 Commit SHA-1 hash:  005db40cd1

Runtime Environment:
 OS Name:     centos
 OS Version:  7
 OS Platform: Linux
 RID:         centos.7-x64
 Base Path:   /tools/dotnet/1.1.0/sdk/1.0.1

Output of dotnet --version in Jenkins

1.0.1

Output of dotnet in Jenkins

Microsoft .NET Core Shared Framework Host

  Version  : 1.1.0
  Build    : 928f77c4bc3f49d892459992fb6e1d5542cb5e86

Output of dotnet restore in Jenkins

Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.

Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.

Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 0%Decompressing 1%Decompressing 2%Decompressing 3%Decompressing 4%Decompressing 5%Decompressing 6%Decompressing 7%Decompressing 8%Decompressing 9%Decompressing 10%Decompressing 11%Decompressing 12%Decompressing 13%Decompressing 14%Decompressing 15%Decompressing 16%Decompressing 17%Decompressing 18%Decompressing 19%Decompressing 20%Decompressing 21%Decompressing 22%Decompressing 23%Decompressing 24%Decompressing 25%Decompressing 26%Decompressing 27%Decompressing 28%Decompressing 29%Decompressing 30%Decompressing 31%Decompressing 32%Decompressing 33%Decompressing 34%Decompressing 35%Decompressing 36%Decompressing 37%Decompressing 38%Decompressing 39%Decompressing 40%Decompressing 41%Decompressing 42%Decompressing 43%Decompressing 44%Decompressing 45%Decompressing 46%Decompressing 47%Decompressing 48%Decompressing 49%Decompressing 50%Decompressing 51%Decompressing 52%Decompressing 53%Decompressing 54%Decompressing 55%Decompressing 56%Decompressing 57%Decompressing 58%Decompressing 59%Decompressing 60%Decompressing 61%Decompressing 62%Decompressing 63%Decompressing 64%Decompressing 65%Decompressing 66%Decompressing 67%Decompressing 68%Decompressing 69%Decompressing 70%Decompressing 71%Decompressing 72%Decompressing 73%Decompressing 74%Decompressing 75%Decompressing 76%Decompressing 77%Decompressing 78%Decompressing 79%Decompressing 80%Decompressing 81%Decompressing 82%Decompressing 83%Decompressing 84%Decompressing 85%Decompressing 86%Decompressing 87%Decompressing 88%Decompressing 89%Decompressing 90%Decompressing 91%Decompressing 92%Decompressing 93%Decompressing 94%Decompressing 95%Decompressing 96%Decompressing 97%Decompressing 98%Decompressing 99%Decompressing 100% 6579 ms
Expanding 0%Expanding 1%Expanding 2%Expanding 3%Expanding 4%Expanding 5%Expanding 6%Expanding 7%Expanding 8%Expanding 9%Expanding 10%Expanding 11%Expanding 12%Expanding 13%Expanding 14%Expanding 15%Expanding 16%Expanding 17%Expanding 18%Expanding 19%Expanding 20%Expanding 21%Expanding 22%Expanding 23%Expanding 24%Expanding 25%Expanding 26%Expanding 27%Expanding 28%Expanding 29%Expanding 30%Expanding 31%Expanding 32%Expanding 33%Expanding 34%Expanding 35%Expanding 36%Expanding 37%Expanding 38%Expanding 39%Expanding 40%Expanding 41%Expanding 42%Expanding 43%Expanding 44%Expanding 45%Expanding 46%Expanding 47%Expanding 48%Expanding 49%Expanding 50%Expanding 51%Expanding 52%Expanding 53%Expanding 54%Expanding 55%Expanding 56%Expanding 57%Expanding 58%Expanding 59%Expanding 60%Expanding 61%Expanding 62%Expanding 63%Expanding 64%Expanding 65%Expanding 66%Expanding 67%Expanding 68%Expanding 69%Expanding 70%Expanding 71%Expanding 72%Expanding 73%Expanding 74%Expanding 75%Expanding 76%Expanding 77%Expanding 78%Expanding 79%Expanding 80%Expanding 81%Expanding 82%Expanding 83%Expanding 84%Expanding 85%Expanding 86%Expanding 87%Expanding 88%Expanding 89%Expanding 90%Expanding 91%Expanding 92%Expanding 93%Expanding 94%Expanding 95%Expanding 96%Expanding 97%Expanding 98%Expanding 99%Expanding 100% 27788 ms
  Restoring packages for /home/jenkins/workspace/prj/prj build/prj.csproj...
  Restoring packages for /home/jenkins/workspace/prj/prj build/prj.csproj...
  Installing Microsoft.NETCore.Jit 1.0.2.
  Installing Microsoft.NETCore.Runtime.CoreCLR 1.0.2.
  Installing Microsoft.NETCore.DotNetHostPolicy 1.0.1.
  Installing Microsoft.NETCore.App 1.0.0.
  Installing Microsoft.DotNet.Watcher.Tools 1.0.0.
  Installing Microsoft.AspNetCore.WebUtilities 1.0.0.
  Installing Microsoft.Extensions.ObjectPool 1.0.0.
  Installing Microsoft.AspNetCore.Http 1.0.0.
  Installing Microsoft.ApplicationInsights.AspNetCore 2.0.0.
  Installing Microsoft.Extensions.Logging 1.0.0.
  Installing Microsoft.Extensions.DependencyInjection 1.0.0.
  Installing Microsoft.Extensions.Configuration.EnvironmentVariables 1.0.0.
  Installing Microsoft.Extensions.Configuration 1.0.0.
  Installing Microsoft.Extensions.DiagnosticAdapter 1.0.0.
  Installing Microsoft.ApplicationInsights 2.2.0.
  Installing Microsoft.Extensions.Configuration.Json 1.0.0.
  Installing Microsoft.Extensions.Options 1.0.0.
  Installing Microsoft.Extensions.Configuration.FileExtensions 1.0.0.
  Installing Microsoft.AspNetCore.Hosting 1.0.0.
  Restore completed in 3.83 sec for /home/jenkins/workspace/prj/prj build/prj.csproj.
  Generating MSBuild file /home/jenkins/workspace/prj/prj build/obj/prj.csproj.nuget.g.props.
  Generating MSBuild file /home/jenkins/workspace/prj/prj build/obj/prj.csproj.nuget.g.targets.
  Writing lock file to disk. Path: /home/jenkins/workspace/prj/prj build/obj/project.assets.json
  Restore completed in 4.96 sec for /home/jenkins/workspace/prj/prj build/prj.csproj.

  NuGet Config files used:
      /home/jenkins/.nuget/NuGet/NuGet.Config

  Feeds used:
      https://api.nuget.org/v3/index.json

  Installed:
      19 package(s) to /home/jenkins/workspace/prj/prj build/prj.csproj

Output of docker info

Containers: 5
 Running: 0
 Paused: 0
 Stopped: 0
Images: 15581
Server Version: 1.9.1
Storage Driver: devicemapper
 Pool Name: appvg-lv_docker_thinpool
 Pool Blocksize: 65.54 kB
 Base Device Size: 107.4 GB
 Backing Filesystem: 
 Data file: 
 Metadata file: 
 Data Space Used: 736.3 GB
 Data Space Total: 1.1 TB
 Data Space Available: 363.2 GB
 Metadata Space Used: 1.04 GB
 Metadata Space Total: 16.98 GB
 Metadata Space Available: 15.94 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Library Version: 1.02.107-RHEL7 (2015-10-14)
Execution Driver: native-0.2
Logging Driver: json-file
Plugins: 
 Volume: 
 Network: 
Kernel Version: 3.10.0-327.4.5.el7.x86_64
Operating System: Red Hat Enterprise Linux
CPUs: 32
Total Memory: 125.7 GiB
Name: labl0002.uhclab.lab
ID: KGDU:S2GA:VRKV:PFM2:TMYI:YA2J:KEID:KRSG:O4JL:EFDC:IBE6:BTU6
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No kernel memory limit support
WARNING: No cpu shares support
WARNING: No cpuset support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

I noticed that dotnet restore installs Microsoft.NETCore.App 1.0.0. Why is that? How can I make it install the right thing?

natemcmaster commented 7 years ago

Can you share your csproj file?

Simon-Vuong commented 7 years ago

Yes. The .csprj file would make sense to add :)

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    <!-- <RuntimeFrameworkVersion>1.0.0</RuntimeFrameworkVersion> -->
  </PropertyGroup>
  <ItemGroup>
    <!--specify wwwroot as the public client folder-->
    <Folder Include="wwwroot\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
  </ItemGroup>
  <!--allows us to run "dotnet watch run" which restarts the client/server respecitively when there is a change in code-->
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
  </ItemGroup>
  <!--<Target Name="Build Angular" Condition="'$(Configuration)'=='Release'" BeforeTargets="Build">
    <Message Text="* * * * * * Building Angular App * * * * * *" Importance="high" />
    <Exec Command="ng build -prod -aot" />
  </Target>-->
</Project>
natemcmaster commented 7 years ago

@SimonVuong / @Simon-Vuong - I followed your steps exactly and was unable to reproduce the issue. The error you got leads me to believe you may have used microsoft/aspnetcore:1.0, microsoft/aspnetcore:2.0, or microsoft/aspnetcore:latest.

I noticed that dotnet restore installs Microsoft.NETCore.App 1.0.0. Why is that? How can I make it install the right thing?

There are two reasons this would appear in the console output.

  1. <RuntimeFrameworkVersion>1.0.0</RuntimeFrameworkVersion>. This overrides the version of Microsoft.NETCore.App. In a netcoreapp1.1 project, RuntimeFrameworkVersion defaults to 1.1.2.
  2. <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />. dotnet-watch is itself a .NET Core 1.0.0 app. It's installation is independent from the TargetFramework value in you project.

By the way, console output can be misleading and is not the best way to determine what is actually restore. The restore result can be found by examining obj/project.assets.json.

SimonVuong commented 7 years ago

I changed the TargetFramework to netcoreapp1.0 and it works. Unfortunately, I'm still a little confused as to what is happening exactly. I suspect my Jenkins dotnet core sdk was 1.0.1 even though the "Microsoft .NET Core Shared Framework Host" was at version 1.1.0.

natemcmaster commented 7 years ago

Ok. I'm closing as there doesn't appear to be any changes required to Docker images.

cnjimbo commented 6 years ago

There is the same problem with my project, the workaround to resolve it successfully is that remove the item 'C:\Program Files (x86)\dotnet' from the Path of Environment Variable because I found I did not install the right netcore version under X86. I have not tried to install the proper version with x86, appreciate that you tell me if you have done that test.