dotnet / corert

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.
http://dot.net
MIT License
2.91k stars 510 forks source link

Publish broken when DisableImplicitFrameworkReferences set #8031

Open kant2002 opened 4 years ago

kant2002 commented 4 years ago

I have 2 projects both of which configured in similar fashion

Runtime

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <NoStdLib>true</NoStdLib>
    <NoConfig>true</NoConfig>
    <RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
  </PropertyGroup>

App

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

    <NoStdLib>true</NoStdLib>
    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
    <NoConfig>true</NoConfig>
    <RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
    <IlcSystemModule>Runtime</IlcSystemModule>
  </PropertyGroup>

This does not work on clean build. and start complaining that could not copy "App.exe" to bin/ location.

I use DisableImplicitFrameworkReferences to not have standard libraries attached to my CSC compilation process, since I use custom runtime.

I'm not sure is this CoreRT tooling, or regular .NET SDK tooling issue.

jkotas commented 4 years ago

That looks like .NET SDK issue. You need to find the place that is trying to copy app.exe to bin in the .NET SDK targets and suppress it somehow.

kant2002 commented 4 years ago

I manage the make it work, but adding following lines:

<SelfContained>false</SelfContained>
<UseAppHost>false</UseAppHost>

And adding

<ItemGroup>
    <LinkerArg Include="/subsystem:console /entry:__managed__Main /merge:.modules=.rdata /merge:.pdata=.rdata /DYNAMICBASE:NO /filealign:16 /align:16" />
  </ItemGroup>

Questions: