Skip to content

Commit

Permalink
Bicep nuget packages fixes
Browse files Browse the repository at this point in the history
Fixes Azure#5253
Fixes Azure#5238
Fixes Azure#5236
  • Loading branch information
stan-sz committed Nov 24, 2021
1 parent ea9d1fd commit be85aff
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
20 changes: 20 additions & 0 deletions src/Bicep.MSBuild.E2eTests/examples/empty/empty.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
Do not include this project in the solution. It is intended to validate our MSBuild task.
-->
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>

<!--
Pickup latest available packages (including prerelease) from local feed configured in NuGet.config.
-->
<ItemGroup>
<PackageReference Include="Azure.Bicep.CommandLine.$(RuntimeSuffix)" Version="*-*" />
<PackageReference Include="Azure.Bicep.MSBuild" Version="*-*" />
</ItemGroup>

<ItemGroup>
<!-- Do not set any Bicep item: this ensures the package correctly does not error on projects without Bicep items -->
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
</ItemGroup>

<ItemGroup>
<!-- the following file name is intentionally wrong -->
<Bicep Include="empty.bicep"/>
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion src/Bicep.MSBuild.E2eTests/examples/multiple/multiple.proj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
-->
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<!-- Ensure the package supports multi-targeting -->
<TargetFrameworks>net5;net472</TargetFrameworks>
<BicepOutputPath>bin\$(Configuration)\templates</BicepOutputPath>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.MSBuild/Bicep.MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<!-- do not upgrade these packages - we need to support mesbuild 16 -->
<!-- do not upgrade these packages - we need to support msbuild 16 -->
<PackageReference Include="Microsoft.Build.Framework" Version="16.10.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.10.0" PrivateAssets="All" />
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/Bicep.MSBuild/build/Azure.Bicep.MSBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<BicepOutputPath Condition=" $(BicepOutputPath) == '' ">$(OutputPath)</BicepOutputPath>
</PropertyGroup>

<Target Name="BicepCompile" Condition=" @(Bicep) != '' " DependsOnTargets="$(BicepCompileDependsOn)" AfterTargets="$(BicepCompileAfterTargets)" BeforeTargets="$(BicepCompileBeforeTargets)">
<Target Name="BeforeBicepCompile" Condition=" @(Bicep) != '' " BeforeTargets="BicepCompile">
<ItemGroup>
<_BicepResolved Include="@(Bicep)">
<!-- populate missing output file metadata using the default path -->
Expand All @@ -16,13 +16,13 @@

<_BicepOutputFile Include="%(_BicepResolved.OutputFile)" />
</ItemGroup>

<!-- pre-create directories for all the outputs in case they don't exist -->
<MakeDir Directories=" %(_BicepOutputFile.RootDir)%(Directory)" />

<Error Text="The path to the Bicep compiler is not set. Reference the appropriate Azure.Bicep.CommandLine.* package for your runtime or set the BicepPath property." Condition=" $(BicepPath) == '' " />
<Bicep SourceFile="%(_BicepResolved.FullPath)" OutputFile="%(OutputFile)" ToolExe="$(BicepPath)" />

</Target>

<Target Name="BicepCompile" Inputs="@(_BicepResolved)" Outputs="%(_BicepResolved.OutputFile)" DependsOnTargets="$(BicepCompileDependsOn)" AfterTargets="$(BicepCompileAfterTargets)" BeforeTargets="$(BicepCompileBeforeTargets)">
<Bicep SourceFile="%(_BicepResolved.FullPath)" OutputFile="%(OutputFile)" ToolExe="$(BicepPath)" YieldDuringToolExecution="true" />
<Message Importance="High" Text="$(MSBuildProjectName) -&gt; %(_BicepResolved.OutputFile)" />

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<Project>
<Import Project="..\build\BicepTasks.props" />
<Import Project="..\build\Azure.Bicep.MSBuild.props" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<Project>
<Import Project="..\build\BicepTasks.targets" />
<Import Project="..\build\Azure.Bicep.MSBuild.targets" />
</Project>

0 comments on commit be85aff

Please sign in to comment.