Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Please help. I failed to set the console application icon in my .csproj file through Visual Studio Code.

I'm trying to make a build for Linux. Here is my error:

Error building Win32 resources -- Icon stream is not in the expected format.


What I have tried:

My .csproj file

XML
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <Description>Proj Server</Description>
    <IsPackable>true</IsPackable>
<ApplicationIcon>build/icons/linux_256x256.png</ApplicationIcon>
  </PropertyGroup>
<ItemGroup>
   <Content Include="build/icons/linux_256x256.png">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
   </Content>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="build/icons/linux_256x256.png" />
</ItemGroup>
  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="ElectronNET.API" Version="5.30.1" />
  </ItemGroup>
  <ItemGroup>
    <Content Update="electron.manifest.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
</Project>
Posted
Updated 27-Jan-22 5:15am
v3

1 solution

Make sure your path is correct and your icon should be .ico format.
<ApplicationIcon>bin/Debug/icons/myIcon.ico</ApplicationIcon>

Or place icon file on your root path and use the following in your csproj file.
<ApplicationIcon>myIcon.ico</ApplicationIcon>
 
Share this answer
 
v2
Comments
DoingWork 27-Jan-22 3:32am    
Thanks for your reply. I want to know that .ico file will work on linux ?
M Imran Ansari 27-Jan-22 3:57am    
It should work. I have tested on Windows and don't have Linux environment to test this. You can check the following links:
https://github.com/dotnet/runtime/issues/48111
https://doc.qt.io/qt-5/appicon.html#setting-the-application-icon-on-common-linux-desktops
DoingWork 27-Jan-22 4:22am    
I am aware with windows but problem with linux. Ok checking shared links

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900