美文网首页
c#条件编译/按需引用 按需打包

c#条件编译/按需引用 按需打包

作者: 吉凶以情迁 | 来源:发表于2023-04-06 14:17 被阅读0次
    <ItemGroup>
        <PackageReference Include="Dapper" Version="2.0.123" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.5" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.1" />
        <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
        <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
        <PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.3" />
        <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.3" />
        <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.2.3" />
        <PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
        <PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
        <PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
        <PackageReference Include="System.ServiceModel.Duplex" Version="4.8.*" />
        <PackageReference Include="System.ServiceModel.Federation" Version="4.8.*" />
        <PackageReference Include="System.ServiceModel.Http" Version="4.8.*" />
        <PackageReference Include="System.ServiceModel.NetTcp" Version="4.8.*" />
        <PackageReference Include="System.ServiceModel.Security" Version="4.8.*" />
        
        <!-- 如果 DefineConstants 中没有定义 NO_SIGNALR 则添加 Microsoft.AspNetCore.SignalR 包 -->
        <PackageReference Include="Microsoft.AspNetCore.SignalR" Condition="!$(DefineConstants.Contains('NO_SIGNALR'))" Version="1.1.0" />
    </ItemGroup>
    

    宏定义控制代码部分是否会编译进去
    也可以在上面的东西里控制
    另外一种技术 根据引用智能的删掉没用到的代码
    https://www.cnblogs.com/rupeng/p/16036266.html

    相关文章

      网友评论

          本文标题:c#条件编译/按需引用 按需打包

          本文链接:https://www.haomeiwen.com/subject/hyruddtx.html