Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

447
Visualizações
The referenced project is a non self-contained executable. A non self-contained executable cannot be referenced by a self-contained executable

I'm having an issue regarding trying to compile my .netcore3.1 after updated the SDK to .NET 6.0 preview while debugging through Visual Studio.

My CSProject is bellow :

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <UserSecretsId>f5884bc9-1eeb-1458-bba9-832ed8f4cd4e</UserSecretsId> 
    
</Project>

my dotnet sdk installed :

.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.5.21302.13
 Commit:    d6380bcae7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-preview.5.21302.13\

Host (useful for support):
  Version: 6.0.0-preview.5.21301.5
  Commit:  ec3e0b276b

.NET SDKs installed:
  1.1.14 [C:\Program Files\dotnet\sdk]
  2.1.519 [C:\Program Files\dotnet\sdk]
  2.2.104 [C:\Program Files\dotnet\sdk]
  3.0.103 [C:\Program Files\dotnet\sdk]
  3.1.300 [C:\Program Files\dotnet\sdk]
  5.0.301 [C:\Program Files\dotnet\sdk]
  6.0.100-preview.5.21302.13 [C:\Program Files\dotnet\sdk]

error messages :

The referenced project is a non self-contained executable. A non self-contained executable cannot be referenced by a self-contained executable.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

According to the documentation, your configuration never did work, but you would only find out when trying to run the referencing application:

In previous .NET SDK versions, you could reference a self-contained executable project from a non-self-contained executable project without a build error. However, both apps would not be runnable. Starting in .NET SDK 5, an error is generated if an executable project references another executable project and the SelfContained values don't match.

Now, you get the error at build time, so that you know then that you need to fix one project or the other so that their "self-contained-ness" matches.

Note that if you are sure you want to mix the SelfContained values in spite of the potential issues, you can disable checking for that condition, by adding <ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained> to the .csproj file.

over 4 years ago · Santiago Trujillo Relatório

0

I have the same issue with .net 3.1 and not SDK5. I think they have fixed something as my application was quite happily working in production and test, and now complains about this.

I updated the publishing settings to be framework dependant and it is now working as expected. Visual studio has just starting building when I save files, which it never used to do. Maybe a VS update as I do those automatically.

over 4 years ago · Santiago Trujillo Relatório

0

To fix this, all the referenced projects, must be self-contained and remove the Platforms tag from all the projects. Click on every project in your solution and make sure that the *.csporoj files have the following setup.

Common.csproj

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
  </PropertyGroup>

App.csproj

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\Common\Common.csproj" />
    <ProjectReference Include="..\AppWorker\AppWorker.csproj">
      <CopyLocal>True</CopyLocal>
      <CopyLocalSatelliteAssemblies>True</CopyLocalSatelliteAssemblies>
    </ProjectReference>
  </ItemGroup>

AppWorker.csproj

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
  </PropertyGroup>

  
  <ItemGroup>
    <ProjectReference Include="..\Common\Common.csproj" />
  </ItemGroup>

Also an important step, when doing the Publish operation, make sure to select Release-AnyCPU. For some reason the other options make the publish to fail and display bad configuration error in the toolbar.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda