Coder Social home page Coder Social logo

vallens / obfuscationsamples Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 13 KB

一个演示如何在`编译后`、`打包前后`、`发布前后`,实现一键`编译`、`混淆`、`打包`、`推送` 到 `NuGet` 的示例。

License: MIT License

C# 100.00%

obfuscationsamples's Introduction

Obfuscation Samples

Summary

一个演示如何在编译后打包前后发布前后,实现一键编译混淆打包推送NuGet 的示例。

示例项目

  • Obfuscation.AfterBuild: 收到编译事件,在编译后,触发混淆、打包、推送到 NuGet
  • Obfuscation.OnPack: 收到打包事件,在打包前(总是在编译完成后),触发混淆。在打包后,推送到 NuGet
  • Obfuscation.OnPublishExe: 收到发布事件,在发布前(总是在编译完成后),触发混淆。在打包后,推送到 NuGet
  • Obfuscation.OnPublishLibrary: 收到发布事件,在打包前(总是在编译完成后),触发混淆。在打包后,推送到 NuGet

Usage

Install package

.NET CLI:

dotnet add package Obfuscation.Tasks --version 1.0.2

or PowerShell:

Install-Package Obfuscation.Tasks -Version 1.0.2

or Edit project items:

<ItemGroup>
  <PackageReference Include="Obfuscation.Tasks" Version="1.0.2">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
</ItemGroup>

Configure ObfuscationTask

Triggered after PostBuildEvent:

<Target Name="Obfuscation" AfterTargets="PostBuildEvent">
  <ObfuscationTask ToolDir="\\192.168.1.155\dll" InputFilePaths="$(TargetPath)" DependencyFiles="" OutputFileNameSuffix="" TimeoutMillisecond="2000" Importance="high">
    <Output TaskParameter="OutputFilePaths" PropertyName="SecuredFilePaths" />
  </ObfuscationTask>
  <Message Text="SecuredFilePaths: $(SecuredFilePaths)" Importance="high" />
</Target>

Or trigger after publication.

Here's a detail, when the OutputType is Library, it needs to depend on the GenerateNuspec target.

When the OutputType is Exe, it needs to depend on the Publish target.

<Target Name="Obfuscation" AfterTargets="GenerateNuspec">
  <ObfuscationTask ToolDir="\\192.168.1.155\dll" InputFilePaths="$(TargetPath)" Importance="low">
    <Output TaskParameter="OutputFilePaths" PropertyName="SecuredFilePaths" />
  </ObfuscationTask>
  <Message Text="SecuredFilePaths: $(SecuredFilePaths)" Importance="high" />
</Target>
  • Input Parameters:

    • ToolDir: Required. Example: \\192.168.1.155\dll
    • InputFilePaths: Required. Single example: D:\sources\ObfuscationSamples\ObfuscationSamples\bin\Release\ObfuscationSamples.dll; Multiple examples: $(TargetPath);D:\ref\Samples1.dll;D:\ref\Samples2.dll
    • DependencyFiles: Optional. Example: $(OutputPath)Serilog.dll;$(OutputPath)Serilog.Sinks.Console.dll
    • TimeoutMillisecond: Optional. Default value: 30000
    • Importance: Optional. Default value: Normal. Options: High, Normal, Low. Reference Message task
    • OutputFileNameSuffix: Optional. Default value: _Secure
  • Output Parameters:

    • OutputFilePaths: string. Default value: $(InputFilePaths)$(OutputFileNameSuffix).dll. Example: D:\sources\ObfuscationSamples\ObfuscationSamples\bin\Release\ObfuscationSamples_Secure.dll

Support

Support MSBuild v15.0 or higher.

Samples

Authors

License

obfuscationsamples's People

Contributors

vallens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

dsb123

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.