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.

Paket dependencies not added to build

See original GitHub issue

Description

Dependencies specified in paket.dependencies are not made available at build time

Repro steps

  1. dotnet paket init
  2. Add dependencies to paket.dependencies, paket.references
  3. dotnet paket install
  4. dotnet paket restore
  5. dotnet build

Example git repository: https://github.com/Craige/paket-test

Expected behavior

Package dependencies should be added to the build. Build should succeed.

Actual behavior

Paket.restore.targets is added to .csproj, but package dependencies are seemingly not added to build. Any references to identifiers from the dependency generates a compilation error (e.g. The type or namespace name ‘%’ could not be found)

➜  PaketTest git:(master) ✗ dotnet build Test/Test.csproj
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Paket version 5.242.2
  Starting restore process.
  Performance:
   - Runtime: 1 second
  Restore completed in 33.51 ms for /Users/craige/Source/PaketTest/Test/Test.csproj.
Manifest.cs(3,12): error CS0246: The type or namespace name 'ModuleAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(3,12): error CS0246: The type or namespace name 'Module' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(4,5): error CS0246: The type or namespace name 'Name' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(5,5): error CS0246: The type or namespace name 'Author' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(6,5): error CS0246: The type or namespace name 'Website' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(7,5): error CS0246: The type or namespace name 'Version' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(8,5): error CS0246: The type or namespace name 'Description' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(9,5): error CS0246: The type or namespace name 'Category' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(1,7): error CS0246: The type or namespace name 'OrchardCore' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(5,7): error CS0246: The type or namespace name 'OrchardCore' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(9,28): error CS0246: The type or namespace name 'StartupBase' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(11,30): error CS0115: 'Startup.ConfigureServices(IServiceCollection)': no suitable method found to override [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(15,30): error CS0115: 'Startup.Configure(IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider)': no suitable method found to override [/Users/craige/Source/PaketTest/Test/Test.csproj]

Build FAILED.

Manifest.cs(3,12): error CS0246: The type or namespace name 'ModuleAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(3,12): error CS0246: The type or namespace name 'Module' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(4,5): error CS0246: The type or namespace name 'Name' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(5,5): error CS0246: The type or namespace name 'Author' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(6,5): error CS0246: The type or namespace name 'Website' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(7,5): error CS0246: The type or namespace name 'Version' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(8,5): error CS0246: The type or namespace name 'Description' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(9,5): error CS0246: The type or namespace name 'Category' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Manifest.cs(1,7): error CS0246: The type or namespace name 'OrchardCore' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(5,7): error CS0246: The type or namespace name 'OrchardCore' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(9,28): error CS0246: The type or namespace name 'StartupBase' could not be found (are you missing a using directive or an assembly reference?) [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(11,30): error CS0115: 'Startup.ConfigureServices(IServiceCollection)': no suitable method found to override [/Users/craige/Source/PaketTest/Test/Test.csproj]
Startup.cs(15,30): error CS0115: 'Startup.Configure(IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider)': no suitable method found to override [/Users/craige/Source/PaketTest/Test/Test.csproj]
    0 Warning(s)
    13 Error(s)

Time Elapsed 00:00:03.37

Build succeeds with these dependencies as <PackageReference>s in .csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="OrchardCore.ContentManagement" Version="1.0.0-rc1-*" />
    <PackageReference Include="OrchardCore.ContentManagement.Abstractions" Version="1.0.0-rc1-*" />
    <PackageReference Include="OrchardCore.Module.Targets" Version="1.0.0-rc1-*" />
  </ItemGroup>
</Project>
➜  PaketTest git:(master) ✗ dotnet build Test/Test.csproj
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 34.15 ms for /Users/craige/Source/PaketTest/Test/Test.csproj.
  Test -> /Users/craige/Source/PaketTest/Test/bin/Debug/netcoreapp3.1/Test.dll
  Test -> /Users/craige/Source/PaketTest/Test/bin/Debug/netcoreapp3.1/Test.Views.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.39

Known workarounds

N/A

Environment

Paket 5.242.2 Dotnet Core 3.1 MacOS 10.14.6

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
h2physicscommented, Jul 12, 2021

Anything updated? I also got an issue when I use target framework net5.0 and paket version 5.258.1. The type or namespace name 'HtmlAgilityPack' could not be found (are you missing a using directive or an assembly reference?) I used dotnet build got the error but when I retry with build action from Visual Studio, the error doesn’t happened? But I need dotnet build for CI so please help me to resolve it

1reaction
Craigecommented, Feb 27, 2020

Oh, my apologies. I misread “pakage” as “paket”. I will fix this and re-try.

Edit: It occurs to me that maybe this should have been caught with a more descriptive error message. NuGet certainly provides feedback about incompatible target frameworks, for example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't use libraries installed with paket tool
I can't use libraries installed with paket tool ... But i can clearly see them added in paket.dependencies, paket.references and paket.lock. So ...
Read more >
The paket.dependencies file
The paket simplify is a heuristic simplification & can sometimes think a dependency is not required in your dependencies file. By adding this...
Read more >
FAQ — Frequently Asked Questions
No, since Paket provides a global view of your dependencies it usually installs only one version of a package and therefore the version...
Read more >
Can't get paket to work for the simplest case : r/fsharp
When I used paket in the past I tend to just do the paket.dependencies at the root of the solution and paket.references in...
Read more >
Getting Started with Paket – Part 1 - The Cockney Coder
The nature of the paket.lock file means that your dependencies cannot drift across projects, since there's only one version per dependency. Note ...
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