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

coreclr build failure: Unable to find package Microsoft.AspNetCore.App.Runtime.win-arm #185

Closed
BruceForstall opened this issue Nov 21, 2019 · 18 comments · Fixed by #225
Closed
Labels
area-Infrastructure-coreclr untriaged New issue has not been triaged by the area owner

Comments

@BruceForstall
Copy link
Member

In a clean runtime clone, I run src\coreclr\build.cmd skipbuildpackages (using skipbuildpackages to get around #181) and after the native test components build, the build fails with:

BUILDTEST: Restoring CoreCLR product from packages
  [11:27:25.30] Restoring all packages...
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.win-arm with version (= 5.0.0-alpha1.19470.6) [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 178 version(s) in dotnet-core [ Nearest version: 5.0.0-alpha1.19472.2 ] [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 11 version(s) in nuget.org [ Nearest version: 3.1.0-preview3.19555.2 ] [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-corefxlab [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-coreclr [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-eng [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet5-transport [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.win-x64 with version (= 5.0.0-alpha1.19470.6) [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 175 version(s) in dotnet-core [ Nearest version: 5.0.0-alpha1.19472.2 ] [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 12 version(s) in nuget.org [ Nearest version: 3.1.0-preview3.19555.2 ] [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-corefxlab [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-coreclr [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-eng [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet5-transport [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.win-x86 with version (= 5.0.0-alpha1.19470.6) [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 151 version(s) in dotnet-core [ Nearest version: 5.0.0-alpha1.19472.2 ] [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 12 version(s) in nuget.org [ Nearest version: 3.1.0-preview3.19555.2 ] [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-corefxlab [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-coreclr [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet-eng [f:\gh\runtime2\src\coreclr\tests\build.proj]
f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj : error NU1102: - Found 0 version(s) in dotnet5-transport [f:\gh\runtime2\src\coreclr\tests\build.proj]
    Restore failed in 803.73 ms for f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj.
f:\gh\runtime2\src\coreclr\tests\build.proj(56,5): error MSB3073: The command ""C:\Program Files\dotnet\dotnet.exe" restore f:\gh\runtime2\src\coreclr\tests\src\Common\test_dependencies\test_dependencies.csproj  /p:SetTFMForRestore=true /p:__BuildOS=Windows_NT /p:__BuildArch=x64 /p:__BuildType=Debug " exited with code 1.

@dotnet/runtime-infrastructure

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Nov 21, 2019
@jkoritzinsky
Copy link
Member

I've seen this in the CoreCLR repo when I've had a 5.0.0 SDK installed on my machine when trying to build. Never quite figured out the underlying issue, but uninstalling the 5.0.0 SDK, deleting the artifacts folder, and deleting the .dotnet folder if it exists usually fixed it for me.

@ViktorHofer
Copy link
Member

Why do we depend on Microsoft.AspNetCore.App.Runtime?

@BruceForstall
Copy link
Member Author

BruceForstall commented Nov 21, 2019

fwiw, I do have dotnet SDK version 5.0.100-alpha1-014888 on my machine

@jkoritzinsky
Copy link
Member

We don't actually depend on it AFAIK. If I remember from my last investigation, for some reason the 5.0.100-* SDK had been grabbed at some point (restore time maybe) and left artifacts around about which FrameworkReferences it had installed. When publishing crossgen2, the 3.0.100 SDK can't find those FrameworkReferences (rightly so) and gets confused (as shown above).

@safern
Copy link
Member

safern commented Nov 21, 2019

I believe this is because the preview SDKs reference all KnownFrameworkReferences directly. Actually if you look at the docs in the dogfooding of the SDK they suggest adding some restore sources.

https://github.com/dotnet/core-sdk#installers-and-binaries

What we can do is remove the AspNetCore and WIndows.Desktop KnownFrameworkReferences.

<KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
<KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />

Also, note that it is the recommendation that you set DOTNET_MULTILEVEL_LOOKUP=0 in your environment globally when building our repos, so that it actually builds using the dotnet specified in the global.json.

@BruceForstall
Copy link
Member Author

Also, note that it is the recommendation that you set DOTNET_MULTILEVEL_LOOKUP=0 in your environment globally when building our repos

Shouldn't our build scripts do that? E.g., build.cmd, build-test.cmd, etc.?

@safern
Copy link
Member

safern commented Nov 21, 2019

Yeah, they should. It seems like build.cmd does as it calls msbuild.ps1 to restore S.P.CoreLib and that goes through tools.ps1

https://github.com/dotnet/runtime/blob/master/eng/common/tools.ps1#L107

So then there something else wrong here that we should investigate.

@ericstj might have some ideas.

@ericstj
Copy link
Member

ericstj commented Nov 21, 2019

/cc @dsplaisted I believe this behavior is expected. The CLI will download these if you don't have them installed and build a standalone app. @safern pointed out how we turn this off for our package testing.

@BruceForstall
Copy link
Member Author

@safern I notice in dotnet.cmd we have:

:: Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
set DOTNET_MULTILEVEL_LOOKUP=0

:: Disable first run since we do not need all ASP.NET packages restored.
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

So that path to invoking dotnet CLI sets it also.

So what is the fix?

@ericstj
Copy link
Member

ericstj commented Nov 22, 2019

If you don't want the CLI to download these, you need to remove the KnownFrameworkReference items.

@BruceForstall
Copy link
Member Author

@ericstj I guess I don't understand: why should my global SDK install have any impact whatsoever on my product build?

And do you mean remove these lines from src\libraries\pkg\test\frameworkSettings\netcoreapp5.0\settings.targets?

<KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
<KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />

because when you write "If you don't want the CLI to download these, you need to remove the KnownFrameworkReference items", it looks to me like those lines, already using "Remove=" syntax, is already going to "remove the KnownFrameworkReference items" -- but I really have no idea what I'm looking at or talking about here.

@ericstj
Copy link
Member

ericstj commented Nov 22, 2019

No, I mean, if you want to restore a self-contained project like https://github.com/dotnet/runtime/blob/master/src/coreclr/tests/src/Common/test_dependencies/test_dependencies.csproj you need to remove the KnownFrameworkReference items yourself, just like we do in our own package testing to avoid the same problem. You'll probably hit this whenever you use a 3.0 or later SDK to restore a self-contained netcoreapp3.0 project, so even if it wasn't something you had to worry about before because you were using an old SDK, you should address it. The fix would be to add those remove items to that test_dependencies.csproj or some common targets file as appropriate. Specifically, copy the following and dump it in that project.

  <ItemGroup>
    <KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
    <KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
  </ItemGroup>

The fact that your build happens to be using the machine wide SDK is because you're launching the restore here:

powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -Command "%__RepoRootDir%\eng\common\msbuild.ps1" %__ArcadeScriptArgs%^
%__ProjectDir%\tests\build.proj -warnAsError:0 /t:BatchRestorePackages /nodeReuse:false^
/p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^
/p:UsePartialNGENOptimization=false /maxcpucount^
%__SkipFXRestoreArg%^
!__Logging! %__CommonMSBuildArgs% %__PriorityArg% %__UnprocessedBuildArgs%

Which uses the dotnet found by the arcade tools:

$buildTool = @{ Path = Join-Path $dotnetRoot "dotnet.exe"; Command = "msbuild"; Tool = "dotnet"; Framework = "netcoreapp2.1" }

I believe it is expected that the arcade tools choose either the local install or machine wide, depending on what satisfies the version listed in global.json.

@ericstj
Copy link
Member

ericstj commented Nov 22, 2019

Also, the reason why this might appear to come and go is that the restore will only be necessary once. After the SDK successfully downloads those runtime packs, it will no longer complain. The version that it needs ends up being tied to the version of the SDK in the global.json. The right fix is to disable this part of the SDK's download using the snippet I shared above. You might do it here, just in case you restore any other projects in this way: https://github.com/dotnet/runtime/blob/64928927e67f48ade7cbb3fc972c3901a5f5696f/src/coreclr/tests/src/Common/Directory.Build.targets

@jkoritzinsky
Copy link
Member

The restore for the projects under coreclr/tests/src/Common actually gets invoked here, which is why it might have problems:

<Target Name="RestorePackage">
<PropertyGroup>
<_ConfigurationProperties>/p:__BuildOS=$(__BuildOS) /p:__BuildArch=$(__BuildArch) /p:__BuildType=$(__BuildType)</_ConfigurationProperties>
<DotnetRestoreCommand Condition="'$(__DistroRid)' == ''">"$(DotNetTool)" restore $(RestoreProj) $(PackageVersionArg) /p:SetTFMForRestore=true $(_ConfigurationProperties) $(__SkipFXRestoreArg)</DotnetRestoreCommand>
<DotnetRestoreCommand Condition="'$(__DistroRid)' != ''">"$(DotNetTool)" restore -r $(__DistroRid) $(RestoreProj) $(PackageVersionArg) /p:SetTFMForRestore=true $(_ConfigurationProperties) $(__SkipFXRestoreArg)</DotnetRestoreCommand>
</PropertyGroup>
<Exec Command="$(DotnetRestoreCommand)"/>
</Target>

@BruceForstall
Copy link
Member Author

I believe it is expected that the arcade tools choose either the local install or machine wide, depending on what satisfies the version listed in global.json.

This seems to be the root of the problem; why would we ever want the machine-wide install?

tools.ps1 has:

# True to attempt using .NET Core already that meets requirements specified in global.json
# installed on the machine instead of downloading one.
[bool]$useInstalledDotNetCli = if (Test-Path variable:useInstalledDotNetCli) { $useInstalledDotNetCli } else { $true }

shouldn't we force useInstalledDotNetCli to false in the build system? It looks like I don't have a ".dotnet" directory, so Arcade (?) decided to always use whatever global version I have installed?

@safern
Copy link
Member

safern commented Nov 22, 2019

shouldn't we force useInstalledDotNetCli to false in the build system? It looks like I don't have a ".dotnet" directory, so Arcade (?) decided to always use whatever global version I have installed?

We specify the version of the dotnet that we want in global.json. So if arcade finds that version installed machine wide, in order to have a faster build, it doesn't install it under .dotnet, it just uses the global one.

However, we also specify in the global.json to allow rolling forward of the sdk for a major version change, so that's why it is picking the new SDK in your machine. This is to allow people building on VS and having a newer SDK installed (without forcing them to install the exact version we depend, machine wide).

runtime/global.json

Lines 3 to 5 in 82d1049

"version": "3.0.100",
"allowPrerelease": true,
"rollForward": "major"

I think it makes sense to add the lines I shared to remove KnownFrameworkReferences into the common tests Directory.Build.targets

@ericstj
Copy link
Member

ericstj commented Nov 22, 2019

I also want to point out that machine wide vs local is red herring. That has nothing to do with the error you are seeing, other than the fact that the version of the SDK determines the version of the runtime packs it tries to install.

@ericstj
Copy link
Member

ericstj commented Nov 22, 2019

After @BruceForstall and @safern and I chatted offline we agreed to do the following:

  1. @BruceForstall will add the KnownFrameworkReference Remove workaround.
  2. @ericstj will file an issue on SDK resolver.
  3. @safern will follow up to consider modification to dotnet/runtime's global.json.

As part of looking into 2, I found that the SDK resolver should actually prefer the closest match: https://github.com/dotnet/core-setup/blob/27063871b42e5c4ee80b8953ebafecb98381d39e/src/corehost/cli/fxr/sdk_resolver.cpp#L376-L400

When I tried this I did observe that behavior. This was a recent change dotnet/core-setup#6953 (/cc @peterhuene @vitek-karas), so its possible the sdkresolver bits you had did not have this fix. Looking at the version of the SDK you had it is 5.0.0-alpha1.19470.6. I believe this build would have fallen in the window where the 5.0 SDK was lagging behind 3.0 and 3.1, I bet if you update to a newer 5.0 machine wide SDK you'll get @peterhuene's feature that handles rollForward and the issue will also go away.

Net result: 2 and 3 should not be needed here. If other folks hit this for early builds of the 5.0 SDK then update to the latest 5.0 SDK to get a fix.

MichalStrehovsky pushed a commit to MichalStrehovsky/runtime that referenced this issue Nov 10, 2020
Merge runtime/master into feature/NativeAOT
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure-coreclr untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants