fsprojects / fsprojects/Paket

Paket resolving analyzer incorrectly in multi-target project

Open
#3,571 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs triage
Dominant language
F#
Stars
2.1k
Forks
528
Avg merge
1d 12m
Merged PRs (30d)
54

Description

AnalyzerIssue.zip

Description

paket resolving non-existent analyzer

Repro steps

Unzip attached solution and build. You will see a compiler error -
1>CSC : error CS0006: Metadata file '.nuget\packages\nservicebus\5.2.26\analyzers\dotnet\cs\NServiceBus.Core.Analyzer.dll' could not be found

Expected behavior

This is a multi-target project - net461 and netstandard2.0
Analyzer is available only in one version of the dependency (NServiceBus 7.x has while NService 5.x doesn't). Paket should resolve the analyzer only netstandard2.0

Actual behavior

analyzer is resolved for both net461 (incorrectly) and netstandard2.0 (correctly)

Known workarounds

As described here - https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1711 - changed my project file to conditionally remove analyzers -

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <Target Name="DisableAnalyzersForVisualStudioBuild" BeforeTargets="CoreCompile" Condition="'$(TargetFramework)' == 'net461'">
    <ItemGroup>
      <Analyzer Remove="@(Analyzer)"/>
    </ItemGroup>
  </Target>
  <Import Project="..\.paket\Paket.Restore.targets" />
</Project>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by unpacking and building the attached AnalyzerIssue.zip solution, then inspect the multi-target project and its imported .paket/Paket.Restore.targets. Compare the analyzer references generated for net461 and netstandard2.0; done means the analyzer is resolved only for netstandard2.0 and the net461 build no longer reports the missing metadata file.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.