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

Build regression from 5.0.6 to 5.0.7 #18178

Open
joshudson opened this issue Jun 9, 2021 · 4 comments
Open

Build regression from 5.0.6 to 5.0.7 #18178

joshudson opened this issue Jun 9, 2021 · 4 comments

Comments

@joshudson
Copy link

C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(993,5): error NETSDK1150: The referenced project '..\Cedaron.Build.CreateAssemblyInfo\Cedaron.Build.CreateAssemblyInfo.csproj' is a non self-contained executable. A non self-contained executable cannot be referenced by a self-contained executable. [src\Cedaron.FormBuilder.Migrate\Cedaron.FormBuilder.Migrate.csproj]

Only happens when building with a rid rather than a rid-independent build

This error doesn't stop the build but returns a nonzero error code from dotnet.exe causing the build chain to fail.

Relevant lines from Cedaron.Build.CreateAssemblyInfo.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <RuntimeFrameworkVersion>5.0.7</RuntimeFrameworkVersion>
    <LangVersion>9.0</LangVersion>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <Target Name="PostcompileScript" AfterTargets="Build">
    <Exec Command="dotnet $(OutputPath)/$(AssemblyName).dll" />
  </Target>

</Project>

Relevant lines from Cedaron.FormBuilder.Migrate.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <RuntimeFrameworkVersion>5.0.7</RuntimeFrameworkVersion>
    <LangVersion>9.0</LangVersion>
    <DebugType>portable</DebugType>
    <OutputType>Exe</OutputType>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="../AssemblyInfo.cs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Cedaron.Common.Loader" Version="1.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Cedaron.Common" Version="2.2.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Cedaron.Build.CreateAssemblyInfo\Cedaron.Build.CreateAssemblyInfo.csproj" Properties="RuntimeIdentifier=">
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <Private>false</Private>
    </ProjectReference>
  </ItemGroup>

So what is this? The ProjectReference is needed because Cedaron.Build.CreateAssemblyInfo.csproj is a dependent project project, but the actual output of Cedaron.Build.CreateAssemblyInfo.csproj is AssemblyInfo.cs; the fact that it produces an executable is a byproduct.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Jun 9, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@jhudsoncedaron
Copy link

Minimized. builds with dotnet build; doesn't build with dotnet build -r win7-x64
18178.zip

@marcpopMSFT
Copy link
Member

See this notice for the workaround and why this was introduced: https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/5.0/referencing-executable-generates-error

@marcpopMSFT marcpopMSFT added Area-NetSDK and removed untriaged Request triage from a team member labels Jun 9, 2021
@marcpopMSFT marcpopMSFT added this to the Discussion milestone Jun 9, 2021
@jhudsoncedaron
Copy link

Ah that link contains the unfortunate text "neither would launch" and neither is CreateAssemblyInfo copied to the output directory so I thought it was talking about something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants