如何使用 Visual Studio Code 在 dotnet 构建中包含资源文件

Cod*_*Lee 7 c# wpf .net-core visual-studio-code

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

文件夹结构

|- Root Folder
   |- bin
      |- Debug
         |- netcoreapp3.1
            |- [this has dlls and exe, but no Resources]
   |- obj
   |- Data
   |- Pages
   |- Resources
      |- images
Run Code Online (Sandbox Code Playgroud)

运行应用程序的命令:

|- Root Folder
   |- bin
      |- Debug
         |- netcoreapp3.1
            |- [this has dlls and exe, but no Resources]
   |- obj
   |- Data
   |- Pages
   |- Resources
      |- images
Run Code Online (Sandbox Code Playgroud)

这些都是标准内容,因此请指出任何丢失的命令、放错位置的文件等。我是 WPF 新手,正在尝试在 VS Code 中构建 Windows 应用程序。

Ant*_*ton 6

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

<EmbeddedResource Include="Resources\images\icon.ico" />
Run Code Online (Sandbox Code Playgroud)

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

<ItemGroup>
   <Content Include="Resources\*.*">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
   </Content>
</ItemGroup>  
Run Code Online (Sandbox Code Playgroud)