【问题标题】:ms build dynamic resource namingms构建动态资源命名
【发布时间】:2015-12-10 09:59:47
【问题描述】:

我想在编译时使用特殊命名将一些文件添加到嵌入式资源中。为此我写在.csproj

<Target Name="BeforeBuild" >
    <ItemGroup>
        <EmbeddedResource Include="..\Bin\$(Configuration)\*.*">
        </EmbeddedResource>
    </ItemGroup>
</Target>

但它总是将&lt;LogicalName&gt; 设置为默认值。 我怎样才能做到这一点?

【问题讨论】:

  • 你确定路径正确吗?你的项目在哪里?我认为你不需要`..`
  • 是的,我确定。这是一个特殊的“bin”文件夹,其中包含来自另一个项目的 dll。
  • 只指定一个不带通配符的文件是否有效:..\Bin\$(Configuration)\SomeFile.ext
  • 是的。它也适用于许多文件。但我找到了解决方案。

标签: c# visual-studio-2012 msbuild csproj


【解决方案1】:

我找到了解决方案。此重命名有效:

<Target Name="BeforeBuild">
    <ItemGroup>
      <Frameworks Include="..\Bin\$(Configuration)\Frameworks\*.*" />
      <Steps Include="..\Bin\$(Configuration)\Steps\*.*" />
    </ItemGroup>
    <ItemGroup>
      <EmbeddedResource Include="@(Frameworks)">
        <LogicalName>Frameworks.%(Filename)%(Extension)</LogicalName>
      </EmbeddedResource>
      <EmbeddedResource Include="@(Steps)">
        <LogicalName>Steps.%(Filename)%(Extension)</LogicalName>
      </EmbeddedResource>
    </ItemGroup>
    <Message Text="EmbeddedResource - @(EmbeddedResource)" />
  </Target>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 2021-02-13
    • 1970-01-01
    • 2021-05-09
    • 2016-01-16
    • 1970-01-01
    • 2020-09-19
    相关资源
    最近更新 更多