简体   繁体   中英

How to get the name of a project/solution from a nuget package

Im making a nuget package for work that will be included in some of our projects. My question is this: Is there a way to get the name of the project that the nuget package will be included in? So far, I've tried this:

Assembly.GetCallingAssembly().GetName().Name

but when I run it, that gives me the name of the project in the Nuget package, rather than the name of the project the Nuget package is included in.

Edit---- The reason I for this is to make a network call to a centralized service from multiple different projects. Getting the project/solution name will be how the calls are differentiated.

Using the EntryAssembly works for me from my nuget package.

Assembly.GetEntryAssembly().GetName().Name

https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.getentryassembly?view=netcore-3.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM