Search Results for

      Show / Hide Table of Contents

      RoslynWeaver Sanitizer

      The RoslynWeaver Sanitizer CLI tool can be used to remove all references of Intent code management attributes and NuGet packages from a Visual Studio solution.

      Removing code management attributes and NuGet references may be needed for situations where a deployment policy prevents inclusion of unapproved/non-essential NuGet packages.

      Note

      Intent code management attributes are passive and contain no processing logic, additionally, because all the attributes have [Conditional("INTENT_ROSLYN_WEAVER_ATTRIBUTES")] applied to them, the C# compiler code does not include them in the generated CIL. The source code for the Intent.RoslynWeaver.Attributes NuGet package is available on GitHub for review.

      Pre-requisites

      Latest release version of .NET.

      Installation

      The tool is available as a .NET Tool and can be installed with the following command:

      dotnet tool install Intent.RoslynWeaverSanitizer.CLI --global
      
      Note

      If dotnet tool install fails with an error to the effect of The required NuGet feed can't be accessed, perhaps because of an Internet connection problem. and it shows a private NuGet feed URL, you can try add the --ignore-failed-sources command line option (source).

      You should see output to the effect of:

      You can invoke the tool using the following command: intent-csharp-code-management-sanitizer
      Tool 'intent.roslynweaversanitizer.cli' (version 'x.x.x') was successfully installed.
      

      Usage

      intent-csharp-code-management-sanitizer <sln-path> [options]

      Arguments

      Argument Description
      <sln-path> The path of the .sln file of the solution to sanitize.

      Options

      Option Description
      --version Show version information
      -?, -h, --help Show help and usage information

      Example: Azure Pipelines

      Create a step to install the tool

      - task: PowerShell@2
        displayName: 'Install the Intent RoslynWeaver Sanitizer'
        inputs:
          targetType: 'inline'
          pwsh: true
          script: 'dotnet tool install Intent.RoslynWeaverSanitizer.CLI --global'
      

      Create a step to run the tool

      - task: PowerShell@2
        displayName: 'Run the Intent RoslynWeaver Sanitizer'
        inputs:
          targetType: 'inline'
          pwsh: true
          script: 'intent-csharp-code-management-sanitizer src/Solution.sln'
      
      Important

      The above two tasks must happen in your pipeline before the task which compiles the Visual Studio solution.

      A complete YAML file

      trigger:
        batch: 'true'
        branches:
          include:
          - '*'
      
      pool:
        vmImage: 'ubuntu-latest'
      
      steps:
      
      - task: PowerShell@2
        displayName: 'Install the Intent RoslynWeaver Sanitizer'
        inputs:
          targetType: 'inline'
          pwsh: true
          script: 'dotnet tool install Intent.RoslynWeaverSanitizer.CLI --global'
      
      - task: PowerShell@2
        displayName: 'Run the Intent RoslynWeaver Sanitizer'
        inputs:
          targetType: 'inline'
          pwsh: true
          script: 'intent-csharp-code-management-sanitizer src/Solution.sln'
      
      - task: DotNetCoreCLI@2
        displayName: 'dotnet publish'
        inputs:
          command: 'publish'
      

      Run the pipeline

      When you run the pipeline, it will install the tool, run it and then compile the solution without any Intent dependencies.

      • Edit this page
      ☀
      ☾
      In this article
      Back to top Copyright © 2017-, Intent Architect Holdings Ltd