Created
October 31, 2025 19:31
-
-
Save JKerens/521ae9ce81d82bc99cd7c02c1fe3fc78 to your computer and use it in GitHub Desktop.
Adding bicep publish-extension into your csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project> | |
| <PropertyGroup> | |
| <!-- All the identifiers to target --> | |
| <RuntimeIdentifiers>win-x64;linux-x64;osx-arm64</RuntimeIdentifiers> | |
| <BicepCmdBase>bicep publish-extension</BicepCmdBase> | |
| <BicepCmdOsx>--bin-osx-arm64 "$(MSBuildProjectDirectory)/bin/$(Configuration)/$(TargetFramework)/osx-arm64/publish/$(AssemblyName)"</BicepCmdOsx> | |
| <BicepCmdLinux>--bin-linux-x64 "$(MSBuildProjectDirectory)/bin/$(Configuration)/$(TargetFramework)/linux-x64/publish/$(AssemblyName)"</BicepCmdLinux> | |
| <BicepCmdWin>--bin-win-x64 "$(MSBuildProjectDirectory)/bin/$(Configuration)/$(TargetFramework)/win-x64/publish/$(AssemblyName).exe"</BicepCmdWin> | |
| <BicepCmdTarget>--target "$(MSBuildProjectDirectory)/bin/$(AssemblyName)"</BicepCmdTarget> | |
| <BicepCmdForce>--force</BicepCmdForce> | |
| <!-- Concatenate all parts into a single command --> | |
| <BicepCommand>$(BicepCmdBase) $(BicepCmdOsx) $(BicepCmdLinux) $(BicepCmdWin) $(BicepCmdTarget) $(BicepCmdForce)</BicepCommand> | |
| </PropertyGroup> | |
| <!-- Make an ItemGroup so I can loop on the Identity property --> | |
| <ItemGroup> | |
| <RIDs Include="$(RuntimeIdentifiers)" /> | |
| </ItemGroup> | |
| <!-- Loops on each RID but sets property BuildingMultiRid=true to avoid an infinite loop --> | |
| <Target Name="PublishForAllRids" BeforeTargets="Publish" Condition="'$(BuildingMultiRid)' != 'true'"> | |
| <MSBuild Projects="$(MSBuildProjectFile)" Targets="Publish" Properties="RuntimeIdentifier=%(RIDs.Identity);BuildingMultiRid=true" BuildInParallel="true" /> | |
| <Message Text="✅ Finishing multi-RID publish for: $(RuntimeIdentifiers)" Importance="high" /> | |
| </Target> | |
| <!-- Call the bundle command but avoid calling it in the 3 runs so $(BuildingMultiRid) != true --> | |
| <Target Name="PackageBicepExtension" | |
| DependsOnTargets="PublishForAllRids" | |
| AfterTargets="Publish" | |
| Condition="'$(BuildingMultiRid)' != 'true'"> | |
| <Message Text="📦 Packaging Bicep extension..." Importance="high" /> | |
| <Exec Command="$(BicepCommand)" /> | |
| </Target> | |
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project Sdk="Microsoft.NET.Sdk"> | |
| <PropertyGroup> | |
| <OutputType>Exe</OutputType> | |
| <RootNamespace>MyExtension</RootNamespace> | |
| <AssemblyName>bicep-ext-myextension</AssemblyName> | |
| <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> | |
| <PublishSingleFile>true</PublishSingleFile> | |
| <SelfContained>true</SelfContained> | |
| <InvariantGlobalization>true</InvariantGlobalization> | |
| <TargetFramework>net9.0</TargetFramework> | |
| <Nullable>enable</Nullable> | |
| <ImplicitUsings>enable</ImplicitUsings> | |
| </PropertyGroup> | |
| <ItemGroup> | |
| <PackageReference Include="Azure.Bicep.Local.Extension" Version="0.38.33" /> | |
| </ItemGroup> | |
| </Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment