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

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

问题描述

我正在Visual Studio代码编辑器中构建具有dotnet核心的WPF应用程序.我遇到的问题是,Builds不包含Resources文件夹,或者看起来是这样.我找不到如何在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="Resources\images\icon.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天全站免登陆