C# Plugin Add Option "Build Yak Package" after creating the project

Hi there,

I have a question.
Do I understand correctly that if I check the option “Build Yak Package” when creating a new Plugin, it will always create a Yak-Package when building the solution, using the information stored in the projects properties (version, autor, …)?

If so, is there a way to add this option once the project was created?
I simply forgot to check this option and I think it would be quite comfortable to have this created automatically.

Thanks,
T.

Yep, this option simply adds this snippet to the end of the .csproj, so you can copy/paste into your project afterwards:

  <Target Name="BuildYakPackage" AfterTargets="DispatchToInnerBuilds">
    <PropertyGroup>
      <YakExecutable Condition="$(YakExecutable) == '' and $([MSBuild]::IsOSPlatform(windows)) and Exists('C:\Program Files\Rhino 8\System\Yak.exe')">C:\Program Files\Rhino 8\System\Yak.exe</YakExecutable>
      <YakExecutable Condition="$(YakExecutable) == '' and $([MSBuild]::IsOSPlatform(macos)) and Exists('/Applications/Rhino 8.app/Contents/Resources/bin/yak')">/Applications/Rhino 8.app/Contents/Resources/bin/yak</YakExecutable>
      
      <BuildYakPackage Condition="$(BuildYakPackage) == '' and $(YakExecutable) != '' and Exists($(YakExecutable))">True</BuildYakPackage>
    </PropertyGroup>
    
    <Warning Text="Could not find Yak executable" Condition="$(YakExecutable) == ''" />

    <ItemGroup>
      <YakPackagesToDelete Include="$(OutputPath)\*.yak;$(OutputPath)\**\manifest.yml" />
    </ItemGroup>
    
    <Delete Files="@(YakPackagesToDelete)" />

    <Exec Command="&quot;$(YakExecutable)&quot; spec" WorkingDirectory="$(OutputPath)" Condition="$(BuildYakPackage) == 'True'" />
    <Exec Command="&quot;$(YakExecutable)&quot; build" WorkingDirectory="$(OutputPath)" Condition="$(BuildYakPackage) == 'True'" />

  </Target>

Hope this helps!

1 Like