MSBuild:将自定义资源文件包含为嵌入资源

koo*_*e98 2 msbuild csproj visual-studio

我在构建时使用MSBuild动态生成资源文件,但为了能够在运行时从该资源文件中读取,我需要它作为嵌入式资源.

我已经到处查看如何在.csproj嵌入式资源中标记文件,我甚至尝试过无效.

<ItemGroup>
  <Content Include="Infrastructure\Content\Store\content_store_en.json" />
  <EmbeddedResource Include="Infrastructure\Content\Store\content_store_en.json">
  </EmbeddedResource>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)

有什么办法可以实现吗?

DeJ*_*aVo 6

这是你如何做到的:

<Target Name="BeforeBuild">
    <CreateItem Include="Infrastructure\**\*.json">
        <Output ItemName="EmbeddedResource" TaskParameter="Include" />
    </CreateItem>
</Target>
Run Code Online (Sandbox Code Playgroud)

资料来源:http://ayende.com/blog/4446/how-to-setup-dynamic-groups-in-msbuild-without-visual-studio-ruining-them

我更改了CreateItem属性,因此它将反映您的问题.

我希望它有所帮助......