Skip to content

Add RoslynVersion configuration in project #207

@atifaziz

Description

@atifaziz

Objective

Implement multi-Roslyn configuration support in src/DocoptNet/DocoptNet.csproj so the project can build analyzer outputs for baseline Roslyn (3.10.0) and Roslyn 4.4.0, with safe packing behavior.

Scope

  • Add RoslynVersion-conditioned property group for Roslyn 4.4 build isolation.
  • Keep baseline behavior unchanged when RoslynVersion is not set.
  • Split Microsoft.CodeAnalysis.CSharp package reference into conditional versions (3.10.0 vs 4.4.0).
  • Add pack item for analyzers/dotnet/roslyn4.4/cs/DocoptNet.dll.
  • Add pre-pack validation target that errors if Roslyn 4.4 analyzer output is missing.

Files

  • src/DocoptNet/DocoptNet.csproj

Tasks

  • Add conditioned PropertyGroup for RoslynVersion == 4.4:
    • Set BaseOutputPath to an isolated Roslyn 4.4 path.
    • Set BaseIntermediateOutputPath to an isolated Roslyn 4.4 path.
    • Add DefineConstants entry for ROSLYN4_4.
  • Replace unconditional Microsoft.CodeAnalysis.CSharp reference with two conditioned references:
    • 3.10.0 for default/empty RoslynVersion.
    • 4.4.0 when RoslynVersion is 4.4.
  • Add second analyzer pack item for analyzers/dotnet/roslyn4.4/cs using MSBuild property-based paths.
  • Add _ValidateRoslyn44AnalyzerOutput target (BeforeTargets="GenerateNuspec") with clear remediation message.

Acceptance Criteria

  • dotnet build at repo root still produces baseline artifacts with no RoslynVersion required.
  • dotnet build src/DocoptNet/DocoptNet.csproj -f netstandard2.0 -p:RoslynVersion=4.4 succeeds and emits isolated output.
  • dotnet pack src/DocoptNet/DocoptNet.csproj fails with explicit guard message if Roslyn 4.4 analyzer output is absent.
  • Changes do not alter lib/ target framework outputs.

Dependencies

  • None.

Notes

  • Use project-relative properties ($(MSBuildProjectDirectory), $(BaseOutputPath), etc.) and avoid hard-coded path separators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions