AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 59 forks source link

[WIP] Add MSBuild Project SDK #108

Closed jarrodldavis closed 5 years ago

jarrodldavis commented 5 years ago

Add a new project that creates an MSBuild Project SDK package that can be used to automatically add the required packages and build-time MSBuild targets to the immediately downstream project. The downstream project is also packaged up as an MSBuild Project SDK so that NuGet-packaged code generators can automatically pull in the CodeGeneration.Roslyn dependencies with a single reference to the generator project.

For example, the generator project will look like this:

<Project Sdk="Microsoft.NET.Sdk">

  <Sdk Name="CodeGeneration.Roslyn.Sdk" Version="0.4.89" />

</Project>

And projects consuming that generator will look like this:

<Project Sdk="Microsoft.NET.Sdk">

  <Sdk Name="MyGenerator" Version="1.0.0" />

</Project>

In both cases, package references, dotnet tool references, targets, and properties will be automatically included without additional configuration.

Things left to do:

amis92 commented 5 years ago

I very much like the idea! I wanted to do something similar :) Tests would be great.

jarrodldavis commented 5 years ago

@AArnott For these tests, I will need NuGet packages to be generated before test execution starts. Do you want to update your Azure Pipelines configurations to handle that or should I make packing the solution's NuGet packages part of the test arrange phase?

AArnott commented 5 years ago

Sorry it's taken slow long to get to this. But I'm super excited at the prospect. I haven't looked at your code change yet.

I will need NuGet packages to be generated before test execution starts. Do you want to update your Azure Pipelines configurations to handle that or should I make packing the solution's NuGet packages part of the test arrange phase?

I would expect all of the build to be done before tests start, including build of packages. This is already in place:

https://github.com/AArnott/CodeGeneration.Roslyn/blob/95003217cec33f70f5a127e6da389b285ac63c59/azure-pipeline.yml#L44

Can you clarify what's missing?

jarrodldavis commented 5 years ago

I would expect all of the build to be done before tests start, including build of packages. This is already in place: Can you clarify what's missing?

Ah, I guess I didn't look closely enough at the pipeline config and was going off of my local development experience. That should work.

Sorry it's taken slow long to get to this. But I'm super excited at the prospect. I haven't looked at your code change yet.

That's alright; I've been busy with a number of other things and still need to work on the tests. I'm going to switch to using Buildalyzer since getting the (in-process) Roslyn build setup with Microsoft's NuGet packages is difficult and brittle.

amis92 commented 5 years ago

Hi @jarrodldavis

Please join me in designing the SDK approach for this project in #113 (Create SDKs).

I'll close this PR for now, because with #114 (DotNetCorePlugins) on my radar the usage will change drastically (hopefully simplifying a lot of stuff).