'Build Error in condition based .csproj file in .net5.0 for Linux and Windows
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)'=='true'">
<TargetFramework>net5.0</TargetFramework>
<Nullable>warnings</Nullable>
<Product>TestClient</Product>
<Authors>Me</Authors>
<Company>MyCompany</Company>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>TestClient</RootNamespace>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<PackagePrefix>TestClient</PackagePrefix>
<PackageName>TestClient_1.0.5</PackageName>
<Version>1.0.5</Version>
<Authors></Authors>
<Company>MyCompany</Company>
<SelfContained>True</SelfContained>
</PropertyGroup>
<ItemGroup Condition="'$(IsLinux)'=='true'">
<Content Include="/home/abc/Repo/TestClient/Deb_Installer/TestClient.desktop" CopyToPublishDirectory="PreserveNewest" LinuxFileMode="1755">
<LinuxPath>/usr/share/applications/TestClient.desktop</LinuxPath>
</Content>
<Content Include="/home/abc/Repo/TestClient/Deb_Installer/TestClient.png" CopyToPublishDirectory="PreserveNewest" LinuxFileMode="1755"/>
<Content Include="/home/abc/Repo/TestClient/TestClient/bin/Desktop/linux-unpacked/**" CopyToPublishDirectory="PreserveNewest" LinuxFileMode="1755"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ElectronNET.API" Version="13.5.1">
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestClient.Common\TestClient.Common.csproj" />
<ProjectReference Include="..\TestClient.DB\TestClient.DB.csproj" />
</ItemGroup>
</Project>
and on building, facing this Error
/usr/share/dotnet/sdk/5.0.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1017,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. [/home/abc/Repo/TestClient/TestClient/TestClient.csproj] /usr/share/dotnet/sdk/5.0.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1017,5): error MSB4018: System.ArgumentException: Invalid input specification: Found multiple entries with the same BundleRelativePath [/home/abc/Repo/TestClient/TestClient/TestClient.csproj] /usr/share/dotnet/sdk/5.0.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1017,5): error MSB4018: at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs) [/home/abc/Repo/TestClient/TestClient/TestClient.csproj] /usr/share/dotnet/sdk/5.0.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1017,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore() [/home/abc/Repo/TestClient/TestClient/TestClient.csproj] /usr/share/dotnet/sdk/5.0.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1017,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() [/home/abc/Repo/TestClient/TestClient/TestClient.csproj] /usr/share/dotnet/sdk/5.0.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1017,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/home/abc/Repo/TestClient/TestClient/TestClient.csproj] /usr/share/dotnet/sdk/5.0.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1017,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/home/abc/Repo/TestClient/TestClient/TestClient.csproj]
Error occurred during dotnet publish: 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
