Buildalyzer icon indicating copy to clipboard operation
Buildalyzer copied to clipboard

Build with generated code

Open bernd5 opened this issue 4 years ago • 4 comments

Hello,

with net 6.0 we get generated code by default (implicit global usings). I would like to load those generated files with Buildalyzer, too.

What should I do?

bernd5 avatar Aug 30 '21 17:08 bernd5

I understand that the latest previews for .NET 6 require an opt-in in the project file (certainly for preview 7), so you would need to add:

<ImplicitUsings>enable</ImplicitUsings>

that said, it should still work, as it shells out to msbuild. So if it works for you with your current SDK, buildalyzer should pick that up and get you some results that match what you are seeing in your IDE / command line.

Update: wrong - It's rc1 that will require the opt-in

slang25 avatar Aug 30 '21 21:08 slang25

In the new templates these implicit usings are enabled by default. I created a test pr with a helloWorld sample without touching the csproj file. The test fails currently.

bernd5 avatar Aug 31 '21 12:08 bernd5

I've ran the test locally here, and it fails due to a weird error, which is the same error I see on all my projects (whatever TFM):

Could not copy the file apphost.exe

I'm not sure why, but when the .NET 6 SDK is present (i.e. installed and not suppressed by a global.json file) then the error crops up. I can work around like this:

System.Environment.SetEnvironmentVariable("UseAppHost", "false");

When I add that to the tests, your TestUsing project compiles successfully. cc @daveaglick

slang25 avatar Sep 06 '21 20:09 slang25

Potential fix: https://github.com/daveaglick/Buildalyzer/pull/187

slang25 avatar Sep 06 '21 21:09 slang25

Merge of solution accomplished

phmonte avatar Feb 18 '24 23:02 phmonte