-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"A self-contained executable cannot be referenced by a non self-contained executable" error on unit tests #17579
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
Comments
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. |
@dsplaisted Looks like you recently adding this validation. How should this interact with unit tests? |
This should be fixed with #17594, but until then you can work around it by setting |
This issue also occurs in .NET 6.0 Preview 5 |
Happening here on SDK 6.0.100-preview.5.21302.13 as well, when is this going to be released? |
This is also happening dotnet 6 Preview 6! This is a big stopper for us and we can't even upgrade to the latest version of dotnet 5 because that also has the problem. @dsplaisted when will this be fixed in dotnet 5 and dotnet 6? |
You should be able to set the If you can share a binlog of your build where you're getting this error, we should be able to look into why it is still triggering for you. |
|
Thanks for the quick binlog. The errors are happening because the projects being referenced are test projects. We fixed the case where a test project was referencing an Exe, but this is the opposite case where an Exe is referencing a test project. I think we should also fix this case. I'm curious though why you have test projects referenced by your app project. Is this intentional? Also, did you try the workaround of setting the |
Yes this is intentional, we have our tests in our code "compiler check"'d out. We have not tried that option |
I've sent a PR to fix this: #18986 |
@dsplaisted We also have this scenario by design. We have our unit tests alongside the code that they test and the files get excluded from release builds. This means that all of our Projects (in Debug mode anyway) are Test Projects |
@dsplaisted after putting in the recommended workaround we get this error:
Full output logs
Binlog: binlog.zip Note that |
some .NET 5 SDKs are affected by dotnet/sdk#17579 Added recommended work-around to ensure production of local NuGet packages still
some .NET 5 SDKs are affected by dotnet/sdk#17579 Added recommended work-around to ensure production of local NuGet packages still
@dsplaisted what is the status of this, do you know when/what versions (.NET 5 and 6) it will be released in? |
It should be in Preview 7 of the .NET 6 SDK. We don't currently plan to fix it in 5.0 SDKs. |
I'm getting the error:
In my scenario, there's a project which is indeed self-contained, and a unit test project which depends on that project and tests it.
This error seems to imply that self-contained projects should not have unit tests, which can't be the case.
An easy workaround is to set
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
, but it seems like the validation is incorrect in this scenario.For reference, the self-contained project looks something like:
and the unit test project:
The text was updated successfully, but these errors were encountered: