Open cataggar opened 1 month ago
Here is the Templates.proj
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Azure-Bicep-Version>0.30.23</Azure-Bicep-Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Bicep.CommandLine.linux-x64" Version="$(Azure-Bicep-Version)" />
<PackageReference Include="Azure.Bicep.CommandLine.osx-arm64" Version="$(Azure-Bicep-Version)" />
<PackageReference Include="Azure.Bicep.CommandLine.win-x64" Version="$(Azure-Bicep-Version)" />
<PackageReference Include="Azure.Bicep.MSBuild" Version="$(Azure-Bicep-Version)" />
</ItemGroup>
<ItemGroup>
<Bicep Include="**/*.bicep" OutputFile="%(RecursiveDir)/%(FileName)-template.json" />
</ItemGroup>
</Project>
If I remove Azure.Bicep.CommandLine.win-x64
, it works, but I need that entry.
It also fails when run on Linux in CI:
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: The specified task executable "/root/.nuget/packages/azure.bicep.commandline.win-x64/0.30.23/build/../tools/bicep.exe" could not be run. System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/root/.nuget/packages/azure.bicep.commandline.win-x64/0.30.23/build/../tools/bicep.exe' with working directory '/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates'. Exec format error [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.StartToolProcess(Process proc) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
On Linux, it tries and fails to use osx-arm64
when it and linux-x64
are restored.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Azure-Bicep-Version>0.30.23</Azure-Bicep-Version>
<!-- Disable lock files as workaround for https://github.com/Azure/bicep/issues/15228 -->
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
<RestoreLockedMode>false</RestoreLockedMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Bicep.CommandLine.linux-x64" Version="$(Azure-Bicep-Version)" Condition="'$(OS)' == 'UNIX'" />
<PackageReference Include="Azure.Bicep.CommandLine.osx-arm64" Version="$(Azure-Bicep-Version)" Condition="'$(OS)' == 'UNIX'" />
<PackageReference Include="Azure.Bicep.CommandLine.win-x64" Version="$(Azure-Bicep-Version)" Condition="'$(OS)' == 'WINDOWS_NT'" />
<PackageReference Include="Azure.Bicep.MSBuild" Version="$(Azure-Bicep-Version)" />
</ItemGroup>
<ItemGroup>
<Bicep Include="**/*.bicep" OutputFile="%(RecursiveDir)/%(FileName)-template.json" />
</ItemGroup>
</Project>
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: The specified task executable "/root/.nuget/packages/azure.bicep.commandline.osx-arm64/0.30.23/build/../tools/bicep" could not be run. System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/root/.nuget/packages/azure.bicep.commandline.osx-arm64/0.30.23/build/../tools/bicep' with working directory '/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates'. Exec format error [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.StartToolProcess(Process proc) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
/root/.nuget/packages/azure.bicep.msbuild/0.30.23/build/Azure.Bicep.MSBuild.targets(66,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [/__w/1/s/src/avs-releases/ev2/ev2/ServiceGroupRoot/Templates/Templates.proj]
The Azure.Bicep.CommandLine.* packages currently assume that only one flavor is referenced by a project so either the first or last one wins. I think we should be able to do our own OS detection and only run the logic from the package that matches the architecture of the machine running the build.
Until we implement this fix, the best workaround is to set the BicepPath
MSBuild property based on the OS you're running on.
@cataggar Does the workaround I shared help with this?
@majastrz. The workaround was a bit more complicated than that. You can see in internal PR https://dev.azure.com/msazure/One/_git/Azure-Dedicated-AVS/pullrequest/10976497 . I had to disabled lock files and support for osx. We would like to be able to use lock files and have it work on Windows, Linux, and Mac.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Azure-Bicep-Version>0.30.23</Azure-Bicep-Version>
<!-- Disable lock files as workaround for https://github.com/Azure/bicep/issues/15228 -->
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
<RestoreLockedMode>false</RestoreLockedMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Bicep.CommandLine.linux-x64" Version="$(Azure-Bicep-Version)" Condition="'$(OS)' == 'UNIX'" />
<!-- Also disable osx-arm64 for same workaround -->
<!-- <PackageReference Include="Azure.Bicep.CommandLine.osx-arm64" Version="$(Azure-Bicep-Version)" Condition="'$(OS)' == 'UNIX'" /> -->
<PackageReference Include="Azure.Bicep.CommandLine.win-x64" Version="$(Azure-Bicep-Version)" Condition="'$(OS)' == 'WINDOWS_NT'" />
<PackageReference Include="Azure.Bicep.MSBuild" Version="$(Azure-Bicep-Version)" />
</ItemGroup>
<ItemGroup>
<Bicep Include="**/*.bicep" OutputFile="%(RecursiveDir)/%(FileName).json" />
</ItemGroup>
</Project>
I looked at the internal PR and that is definitely not a great experience. The platform/arch specific packages are basically just a way to set BicepPath. My fix will make the packages skip their logic unless the OS matches the package itself.
We lock or dependencies and would like
dotnet build -t:BicepCompile
to work on Windows, Linux, and Mac. We are restoring all three native executable packages. It is just a little more disk space. The problem is that when I run it on my Mac, it is trying to run thewin-x64
build ofbicep.exe
. Seems like a bug.