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

Can I use the NoTargets SDK to just generate the source? #579

Open
aetos382 opened this issue Oct 11, 2024 · 0 comments
Open

Can I use the NoTargets SDK to just generate the source? #579

aetos382 opened this issue Oct 11, 2024 · 0 comments

Comments

@aetos382
Copy link

I want to create a project that uses Roslyn Source Generator to generate sources but does not build them.
The purpose is to import the sources generated by this project in another project.
Is this possible?

I wrote the following project and the Generated folder is generated, but the sources are not.

<Project Sdk="Microsoft.Build.NoTargets/3.7.56">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
    <CompilerGeneratedFilesOutputPath>$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', 'Generated'))</CompilerGeneratedFilesOutputPath>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyGenerator\MyGenerator.csproj">
      <OutputItemType>analyzer</OutputItemType>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
    </ProjectReference>
  </ItemGroup>

</Project>
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

1 participant