如何使用 Visual Studio Code 在 dotnet 构建中包含资源文件 [英] How to include Resource files in dotnet build with Visual Studio Code

查看:47
本文介绍了如何使用 Visual Studio Code 在 dotnet 构建中包含资源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Visual Studio 代码编辑器中构建一个带有 dotnet 核心的 WPF 应用程序.我遇到的问题是资源文件夹不包含在构建中,或者看起来是这样.我找不到如何在 Visual Studio 之外执行此操作的示例,并且我尝试使用的任何图像都不起作用.任何提示或示例将不胜感激!

I'm building a WPF application with dotnet core in the visual studio code editor. The problem I'm having is that the Resources folder isn't included with builds, or so it seems. I can't find an example of how to to do that outside of Visual Studio and any image I try to use doesn't work. Any tips or examples would be appreciated!

文件夹结构

|- Root Folder
   |- bin
      |- Debug
         |- netcoreapp3.1
            |- [this has dlls and exe, but no Resources]
   |- obj
   |- Data
   |- Pages
   |- Resources
      |- images

运行应用的命令:

dotnet clean
dotnet build
dotnet run

这都是标准的东西,所以请指出任何丢失的命令、错位的文件等.我是 WPF 的新手,正在尝试在 VS Code 中构建 Windows 应用程序.

It's all standard stuff so please point out any missing commands, misplaced files, etc. I'm new to WPF and trying to build windows app in VS Code.

推荐答案

如果您想将其用作嵌入式资源,只需手动将您的资源文件添加到 .csproj 文件中:

Just add your resource file manually to .csproj file if you want to use it as embedded resource:

<EmbeddedResource Include="Resourcesimagesicon.ico" />

或者如果您想将文件复制到构建文件夹

or if you want to copy files to your build folder

<ItemGroup>
   <Content Include="Resources*.*">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
   </Content>
</ItemGroup>  

这篇关于如何使用 Visual Studio Code 在 dotnet 构建中包含资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆