question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pack library with analyzer

See original GitHub issue

It is common to have:

Lib.csproj
Lib.Analyzers.csproj

Where Lib.csproj does not have a project reference to Lib.Analyzers.csproj but we want Lib.nupkg to have package dependency to Lib.Analyzers.nupkg

When using paket for packing it is just a matter of adding the following to paket.template:

dependencies
  Lib.Analyzers

I tried adding a fake project reference as a hack

  <ItemGroup>
    <ProjectReference Include="..\Lib.Analyzers\Lib.Analyzers.csproj">
      <!-- hack for packing with package dependency -->
      <PrivateAssets>none</PrivateAssets>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
      <UndefineProperties>TargetFramework</UndefineProperties>
    </ProjectReference>
  </ItemGroup>

But it did not work and had issues when building.

Is there support for this scenario and if so where is it documented?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jnm2commented, Nov 20, 2020

What happens if you add SkipGetTargetFrameworkProperties="True" to the project reference? (https://gist.github.com/rainersigwald/1fbd21a24a41b9b7c6204cb9cfcbb1cf#disabling-targetframework-negotiation)

1reaction
ericstjcommented, Jan 27, 2020

I think nuget/home might be a better repository. NuGet owns the Pack task and pack gets all its information about dependencies from the csproj (actually assets file, I believe).

any magic metadata that would allow us to work around this?

One thing you might want to try: https://docs.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2019#projectreference

<ProjectReference Include="..\Lib.Analyzers\Lib.Analyzers.csproj" ReferenceOutputAssembly="False" />
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pack library with analyzer · Issue #429 · dotnet/roslyn-sdk
A project reference from your self-packing library project to your self-packing analyzer project is the easiest way to end up with a library...
Read more >
analyzer | Dart Package
This package provides a library that performs static analysis of Dart code. It is useful for tool integration and embedding. End-users should use...
Read more >
Create a NuGet package for your analyzer
If you are using a .NET Core or .NET Standard project for your analyzers consider using the support for creating NuGet packages present...
Read more >
Code Analysis - Build and Deploy Libraries with Integrated ...
In this article, I'll explain how to bundle libraries and analyzers into NuGet packages for online deployment, showing how you can offer ...
Read more >
Webpack Bundle Analyzer
Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap. Latest version: 4.9.0, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found