Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.Extensions.Http is not being copied #110213

Closed
santo998 opened this issue Nov 27, 2024 · 6 comments
Closed

Microsoft.Extensions.Http is not being copied #110213

santo998 opened this issue Nov 27, 2024 · 6 comments

Comments

@santo998
Copy link

Description

I have a DLL which uses Microsoft.Extensions.Http.

Then, I have a project which references my DLL.

When I run my project, it throws the exception:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Http, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.Http, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
...

If I reference Microsoft.Extensions.Http nuget from my project, it doesn't.

But, I shouldn't have to, because it doesn't reference it directly.

I think making the nuget package being transitive or copying the Microsoft.Extensions.Http DLL in some way via nuget would resolve this, so that's why I'm creating this issue.

Reproduction Steps

Have a DLL which references Microsoft.Extensions.Http, implement some method which uses that nuget package and call that method from another project.

Expected behavior

The project runs

Actual behavior

Exception thrown

Regression?

No response

Known Workarounds

Including direct reference to the nuget package from the project

Configuration

I'm running .NET 8 and referencing Microsoft.Extensions.Http 9.0.0

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 27, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

@huoyaoyuan
Copy link
Member

How are you referencing your dll?

I think making the nuget package being transitive or copying the Microsoft.Extensions.Http DLL in some way via nuget would resolve this

If you are using ProjectReference or packaging nuget properly, the dependency will be transitive.

@ViktorHofer
Copy link
Member

Please share a repro. Nuget dependencies are transitive by default.

@santo998
Copy link
Author

ConsoleApp1.zip

@ViktorHofer here is a sample solution where the exception is thrown.

Notice the class library is referenced as assembly, and not as a project.

Also, the Microsoft.Extensions.Http nuget isn't referenced as transitive in the console app project.

Even more, and probably related to this:
In Program.cs there isn't a using to the custom extension method I defined.

@huoyaoyuan
Copy link
Member

Notice the class library is referenced as assembly, and not as a project.

It's not recommended, and will never work as intended. Assembly is a lower level concept than projects or packages, it's doesn't have information about packages.

@ViktorHofer
Copy link
Member

ViktorHofer commented Nov 28, 2024

@santo998 as @huoyaoyuan mentioned, using Reference doesn't flow package references transitively. We recommend using ProjectReference for referencing other projects which also handles building the project as a dependency of the console app. Closing as by design.

@ViktorHofer ViktorHofer closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants