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

Question: DesignTime build, NuGet Restore, IntelliSense interactions with code generation #5865

Open
japj opened this issue Nov 3, 2020 · 0 comments
Labels

Comments

@japj
Copy link

japj commented Nov 3, 2020

Hello,

I am not sure if this belongs in the msbuild or project-system repository (since this not dotnet specific), but I have some questions on DesignTime build, NuGet Restore, IntelliSense interactions with code generation.

Since this sounds/looks like a generic problem (with code generation) my questions are:

  • is there a good example on how to "correctly" implement MSBuild DesignTime logic and code generation when depending on NuGet packages for input and/or MSBuild Targets
  • is there documentation that explains this consistently (I found snippets here and there and some blogpost, but nothing definitive on the total overview for this scenario)
  • is there a way to trigger a DesignTime build after Restore is done? (if that is how it should be done)
  • is there a way to trigger a DesignTime build if input file changes (so new generated files can be indexed by IntelliSense)

Some more detailed information on the scenario:

  • an Assembly project with custom code generation
  • the custom code generator is "implemented" with an MSBuild Sdk
    • after generating source files, these are added to the relevant Compile ItemGroup depending on language (c#/c++)
  • the input for the code generator is typically stored in the project folder, but there is also a "type-import" mechanism that depends on other xml files acquired through a PackageReference (nuget package)
    • the generated code (filenames) depends on the (imported) input
  • we want IntelliSense on the generated code
    • this implies we need to do "something" during DesignTime builds, so IntelliSense knows about the generated files
  • "consumers" of the generated Assembly are within the same solution

We currently implemented the "IntelliSense support" by actually running the code generator during the DesignTime build.
This works fine when code generation is not using "type-import" (since the input is self-contained).
However it seems to "break" when needing "type-import":

  • the DesignTime build seems to run before (or parallel) to NuGet Restore on a clean solution. The code generation fails and causes some follow-up errors (which it does not seem to be able to recover from)
  • manual workaround is restoring the solution before opening up visual studio

Hope this all makes sense a bit.

@jjmew jjmew transferred this issue from dotnet/project-system Nov 6, 2020
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants