【问题标题】:EmbeddedResource not working inside TargetEmbeddedResource 在 Target 中不起作用
【发布时间】:2019-10-03 12:32:21
【问题描述】:

我有一些 TypescriptCompile 文件,然后我想将它们嵌入到我的 .dll 中。我不得不迁移到新的 csproj 格式,现在我无法在 Target 中嵌入。

这行得通:

<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
       <TargetFramework>net472</TargetFramework>
   </PropertyGroup>
   <ItemGroup>
       <EmbeddedResource  Include="testFile.ts" />
   </ItemGroup>
</Project>

虽然不是这样:

<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
       <TargetFramework>net472</TargetFramework>
   </PropertyGroup>
   <Target Name="AddGeneratedToBuildOutput" BeforeTargets="CoreCompile">
       <ItemGroup>
           <PackageFiles Include="$(MSBuildProjectDirectory)\**\*.*;"/>
       </ItemGroup>
       <Message Text="The target is called: %(PackageFiles.FullPath)" Importance="high"/>
       <ItemGroup>
           <EmbeddedResource  Include="testFile.ts" />          
       </ItemGroup>
    </Target>
</Project>

请注意,消息被写入并且引用的文件在项目中,因此我们可以确定目标被调用。

我已经尝试了其他目标而不是 CoreCompile,但由于我使用的是 TypeScriptCompile,如果我使用 BeforeBuildBuildResolveReferences,我会收到编译错误,因为尚未生成 .js 文件。

我正在使用 JetBrains 的 DotPeek 检查资源并使用 msbuild 15.0。

【问题讨论】:

    标签: msbuild csproj


    【解决方案1】:

    这个问题的解决方法在这里:https://github.com/microsoft/msbuild/issues/4778

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-24
      • 2021-08-21
      相关资源
      最近更新 更多