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

RID-specific self-contained .NET Core 3 app with dependency on Microsoft.NETCore.App 2.0.0 fails to run #3582

Open
dsplaisted opened this issue Aug 28, 2019 · 1 comment

Comments

@dsplaisted
Copy link
Member

Repro

Build and run the following project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <SelfContained>false</SelfContained>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App" Version="2.0.0" />
  </ItemGroup>
</Project>

Expected

Project runs successfully

Actual

Project fails to run with error messages such as the following:

  • A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.0.0-preview9.19416.11'.

  • The specified framework 'Microsoft.NETCore.App', version '3.0.0-preview9-19409-16' was not found.

The output folder also includes the following files, which come from the Microsoft.NETCore.App 2.0.0 package closure:

  • apphost.exe
  • hostfxr.dll
  • hostpolicy.dll
  • System.Private.CoreLib.dll

Details

NuGet/Home#7344 would fix this. Alternatively, we could try to use conflict resolution to exclude these extra assets. That would probably require updating the platform manifest in the targeting pack.

@dsplaisted
Copy link
Member Author

Test case for this bug:

        [Fact]
        public void Apphost_pack_overrides_apphost_from_package()
        {
            var testProject = new TestProject()
            {
                Name="ApphostConflict",
                TargetFrameworks = "netcoreapp3.0",
                RuntimeIdentifier = EnvironmentInfo.GetCompatibleRid(),
                IsSdkProject = true,
                IsExe = true,
                AdditionalProperties =
                {
                    ["SelfContained"] = "false"
                }
            };

            testProject.PackageReferences.Add(new TestPackageReference("Microsoft.NETCore.App", "2.0.0"));

            var testAsset = _testAssetsManager.CreateTestProject(testProject)
                .Restore(Log, testProject.Name);

            var buildCommand = new BuildCommand(Log, testAsset.TestRoot, testProject.Name);

            buildCommand.Execute()
                .Should()
                .Pass();

            var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks, runtimeIdentifier: testProject.RuntimeIdentifier);

            var hostExecutable = $"{testProject.Name}{Constants.ExeSuffix}";
            outputDirectory.Should().OnlyHaveFiles(new[]
            {
                hostExecutable,
                $"{testProject.Name}.dll",
                $"{testProject.Name}.pdb",
                $"{testProject.Name}.deps.json",
                $"{testProject.Name}.runtimeconfig.json",
                $"{testProject.Name}.runtimeconfig.dev.json",
            });

            new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, hostExecutable))
                .Execute()
                .Should()
                .Pass();
        }

dsplaisted added a commit to dsplaisted/sdk that referenced this issue Aug 28, 2019
dsplaisted pushed a commit to dsplaisted/sdk that referenced this issue Feb 19, 2020
…0191115.1 (dotnet#3582)

- Microsoft.Build.Localization - 16.4.0-preview-19565-01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant