Closed amis92 closed 4 years ago
Until new Plugin.Sdk is published, the workaround in the generator project is as follows:
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="CodeGeneration.Roslyn.Plugin.Sdk" Version="0.7.43-alpha" />
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetsForTfmSpecificContentInPackage>
_SetNoBuildForGeneratePackageOnBuild;
$(TargetsForTfmSpecificContentInPackage);
</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>
<Target Name="_SetNoBuildForGeneratePackageOnBuild" Condition=" '$(GeneratePackageOnBuild)' == 'true' ">
<PropertyGroup>
<NoBuild>true</NoBuild>
</PropertyGroup>
</Target>
</Project>
Example error: https://github.com/amis92/RecordGenerator/runs/545333929?check_suite_focus=true#step:5:21
After quick investigation, this is caused by
GeneratePackageOnBuild=true
in the failing project.Circular dependency happens because:
Build
runsGeneratePackageOnBuild=true
,Pack
runs afterBuild
Pack
calls_WalkEachTargetPerFramework
, which in the end runsTargetsForTfmSpecificContentInPackage
CG.R.Plugin.Sdk
adds it'sPackCodeGenerationRoslynPlugin
to that listPackCodeGenerationRoslynPlugin
depends onPublish
Publish
depends onBuild
To stop the circle, we should set
NoBuild=true
inTargetsForTfmSpecificContentInPackage
whenGeneratePackageOnBuild=true
- this will stopPublish
from depending onBuild
.