Skip to content

Autogenerated project is not able to reference a self-contained executable #2076

Open
@ShinyCraig

Description

@ShinyCraig

I'm trying to benchmark code in a self-contained project and am encountering an issue where the autogenerated project is not being generated as a self-contained project leading to this error when I try to run my benchmark.

// Build Error: Standard output: 
  
 Standard error: 
 Time Elapsed 00:00:00.41
    1 Error(s)
    0 Warning(s)
C:\Program Files\dotnet\sdk\6.0.303\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1096,5): error NETSDK1151: The referenced project '..\..\..\..\..\..\ExeProject\ExeProject.csproj' is a self-contained executable.  A self-contained
executable cannot be referenced by a non self-contained executable.  For more information, see https://aka.ms/netsdk1151 [C:\Branches\Benchmarknet6win\Benchmarknet6win\bin\Release\net6.0-windows\win-x64\583881de-f153-4b54-9427-92e7509799da\Be
nchmarkDotNet.Autogenerated.csproj]
Build FAILED.
C:\Program Files\dotnet\sdk\6.0.303\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1096,5): error NETSDK1151: The referenced project '..\..\..\..\..\..\ExeProject\ExeProject.csproj' is a self-contained executable.  A self-contained
executable cannot be referenced by a non self-contained executable.  For more information, see https://aka.ms/netsdk1151 [C:\Branches\Benchmarknet6win\Benchmarknet6win\bin\Release\net6.0-windows\win-x64\583881de-f153-4b54-9427-92e7509799da\Be
nchmarkDotNet.Autogenerated.csproj]
Copyright (C) Microsoft Corporation. All rights reserved.
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET

// BenchmarkDotNet has failed to build the auto-generated boilerplate code.
// It can be found in C:\Branches\Benchmarknet6win\Benchmarknet6win\bin\Release\net6.0-windows\win-x64\583881de-f153-4b54-9427-92e7509799da
// Please follow the troubleshooting guide: https://benchmarkdotnet.org/articles/guides/troubleshooting.html

All of the projects in my benchmarking solution have true in them, but the generated csproj does not. I'm unsure how to properly set up my projects such that the project generated by benchmarkdotnet is also SelfContained, or if there's another way to do this without making my original code not self-contained I am all ears.

The set up of my project is I have a exe project with some code I want to test. A benchmark project with some code that calls code from the exe project, and a "runner" project that calls var result = BenchmarkRunner.Run<MyBenchmark>();

Thanks for any assistance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions