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 with generated code #185

Closed
bernd5 opened this issue Aug 30, 2021 · 5 comments
Closed

Build with generated code #185

bernd5 opened this issue Aug 30, 2021 · 5 comments

Comments

@bernd5
Copy link
Contributor

bernd5 commented Aug 30, 2021

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?

@slang25
Copy link
Contributor

slang25 commented Aug 30, 2021

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

@bernd5
Copy link
Contributor Author

bernd5 commented Aug 31, 2021

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.

@slang25
Copy link
Contributor

slang25 commented Sep 6, 2021

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
Copy link
Contributor

slang25 commented Sep 6, 2021

Potential fix: #187

daveaglick added a commit that referenced this issue Jan 19, 2022
…tputFiles to control output files for design-time builds instead (#194, #185, #187)
@phmonte
Copy link
Owner

phmonte commented Feb 18, 2024

Merge of solution accomplished

@phmonte phmonte closed this as completed Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants