简体   繁体   中英

Possibility to avoid adding nuget package reference in favor of assembly reference incl. dependencies?

is there a way to avoid nuget package references to ease development on a developers machine?

we are currently about to move some of our projects in our " shared " solution to the new csproj file structure (using <Project Sdk="Microsoft.NET.Sdk"> ) and using <TargetFramework>netstandard2.0</TargetFramework> .

By doing so we had to include <PackageReference Include="System.Text.Encodings.Web" Version="4.7.0" /> and changing some of our code in project " S " of our shared solution.

Within another solution backend we are having multiple projects. Some of them are referencing the assembly of project S by using assembly reference to S.dll like so:

<Reference Include="ournamespace.S">
   <HintPath>..\..\artifacts\Shared\ournamespace.S\ournamespace.S.dll</HintPath>
</Reference>

When we build every works fine. However when running our web application W from backend solution we get this exception:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Encodings.Web, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

Before we have migrated our shared projects to the "new SDK" project file format, before using .netstandard2.0 (we were using .net framework 4.7.2) and before we switched the package reference to System.Text.Encodings.Web (we were using <PackageReference Include="AntiXSS" Version="4.3.0" /> ) we have not received any error.

The only way i can think of is that we would need to switch from assembly reference for S.dll to use nuget - to get S dependencies.

However using nuget packages for our shared solutions projects and developing in backend projects would become a nightmare as we would need to create a new nuget package (and publishing it) on every change of S and would need to increase the version number in the package references in backend projects all the time. Also this would become very impractical as our developers are using various git feature branches too (thinking about versioning conflicts; having to release unfinished packages and maybe using version suffix "alpha_"+{branchName} to distinct the branch that this version is coming from).

How to develop on localhost? Is there a way to avoid nuget (but getting its dependencies resolved correctly!)?

I was already reading about having assembly references for local development while using nuget package references for CI builds by using conditionals in the csproj file (however this is also not working very well with VS2017; also this would not resolve our problem with the dependency problem written above on localhost)

What other possibilities are there? Is there a best way on how to handle this?

Thanks in advance!

PS I dont want to include S 's dependencies to every project that references S by using package references there as well. This would not be a solution and becomes more cumbersome when S might get new dependencies for whatever reason.

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

解决了我的问题(有关详细信息,请参阅如何获取 .NET Core 项目以复制 NuGet 引用以构建输出?

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