如何将图标添加到 dotnet 桌面 (Windows) 应用程序? [英] How add icon to dotnet desktop (Windows) application?
问题描述
我只使用了 dotnet
行命令,用于生成项目和生成解决方案"(.sln
),但是我不知道它是否是可以将 resource.rc
直接与 dotnet
一起使用,例如:
I have only used the dotnet
line commands, both to generate projects and to generate "solutions" (.sln
), however I don't know if it is possible to use resource.rc
directly withdotnet
with something like:
MAINICON ICON "icon.ico"
问题是,如何使用 resource.rc
(或其他方式)为标准 .NET 核心应用程序添加图标?
The question is, how can I add with resource.rc
(or other means) an icon for a standard .NET-core application?
除了 dotnet
(CLI) 之外,我还需要其他工具吗?
Will I need any tools other than dotnet
(CLI) for this?
推荐答案
今天我做了一个测试,显然该标签适用于 netcoreapp3.1
:
Today I did a test and apparently the tag works on netcoreapp3.1
:
<ApplicationIcon>nome.ico</ApplicationIcon>
显然该项目必须是一个应用程序,就我而言,我创建了一个控制台"应用程序,如下所示:
Obviously the project has to be an application, in my case I created a "console" application like this:
mkdir projeto1
cd projeto1
dotnet new console
于是我生成了projeto1.csproj
,我打开后是这样编辑的:
So I was generated projeto1.csproj
, I opened it and edited this way:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ApplicationIcon>nome.ico</ApplicationIcon>
</PropertyGroup>
</Project>
然后我运行 dotnet run 并使用 c Debug 和 c Release 标志(并且也发布)这有效,我做的例子:
So then I ran dotnet run and using both the c Debug and c Release flags (and publish also) this works, the example I did:
所以我运行了 dotnet build
并得到了想要的:
So I ran dotnet build
and got the desired one:
这篇关于如何将图标添加到 dotnet 桌面 (Windows) 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!