首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >针对使用MSBuild的.Net核心项目的ILRepack

针对使用MSBuild的.Net核心项目的ILRepack
EN

Stack Overflow用户
提问于 2018-01-09 22:01:39
回答 1查看 4.5K关注 0票数 1

我想在我的MSBuild管道中集成.Net核心项目的ILRepack,以便将所有需要的dll合并到单个exe/dll中。

有用的NuGet-Package ILRepack.MSBuild.Task似乎非常适合这一点,但是GitHub自述文件中的示例不太适用于.Net核心项目,我不知道如何更改它才能与.Net核心项目兼容:

代码语言:javascript
复制
<!-- ILRepack -->
<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">

   <ItemGroup>
    <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge1.dll" />
    <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge2.dll" />
    <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge3.dll" />
   </ItemGroup>

   <ItemGroup>
    <!-- Must be a fully qualified name -->
    <DoNotInternalizeAssemblies Include="ExampleAssemblyToMerge3" />
   </ItemGroup>

   <ILRepack 
    Parallel="true"
    Internalize="true"
    InternalizeExclude="@(DoNotInternalizeAssemblies)"
    InputAssemblies="@(InputAssemblies)"
    TargetKind="Dll"
    OutputFile="$(OutputPath)\$(AssemblyName).dll"
   />

</Target>
<!-- /ILRepack -->

澄清:

我只想使用.Net--Format引入的.csproj-Format,但实际上使用的是net461作为TargetPlatform

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-09 22:01:39

将此用于.Net核心项目:

代码语言:javascript
复制
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net461</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="ILRepack" Version="2.0.15" />
        <PackageReference Include="ILRepack.MSBuild.Task" Version="1.0.9" />
    </ItemGroup>

    <!-- ILRepack -->
    <Target Name="ILRepack" AfterTargets="Build">

        <ItemGroup>
            <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge1.dll" />
            <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge2.dll" />
            <InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge3.dll" />
        </ItemGroup>

        <ItemGroup>
            <!-- Must be a fully qualified name -->
            <DoNotInternalizeAssemblies Include="ExampleAssemblyToMerge3" />
        </ItemGroup>

        <ILRepack
            Parallel="true"
            Internalize="true"
            InternalizeExclude="@(DoNotInternalizeAssemblies)"
            InputAssemblies="@(InputAssemblies)"
            TargetKind="Dll"
            OutputFile="$(OutputPath)\$(AssemblyName).dll" />

    </Target>
    <!-- /ILRepack -->

</Project>

备注

您也可以使用一个<InputAssemblies Include="$(OutputPath)\*.dll" />来合并输出文件夹中的所有dll文件

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48169876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档