简体   繁体   English

避免添加 nuget 包引用以支持程序集引用的可能性,包括。 依赖?

[英]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?有没有办法避免 nuget 包引用以简化开发人员机器上的开发?

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> .我们目前正准备将“共享”解决方案中的一些项目移动到新的csproj 文件结构(使用<Project Sdk="Microsoft.NET.Sdk"> )并使用<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.通过这样做,我们必须包含<PackageReference Include="System.Text.Encodings.Web" Version="4.7.0" />并更改我们共享解决方案的项目“ S ”中的一些代码。

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:其中一些通过使用对S.dll程序集引用来引用项目S的程序集, S.dll所示:

<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:但是,当从后端解决方案运行我们的 Web 应用程序W 时,我们会收到此异常:

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.我们将共享项目迁移到“新 SDK”项目文件格式之前,在使用 .netstandard2.0(我们使用的是 .net framework 4.7.2)之前以及在我们将包引用切换到 System.Text.Encodings.Web 之前(我们使用的是<PackageReference Include="AntiXSS" Version="4.3.0" /> ) 我们没有收到任何错误。

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.我能想到的唯一方法是我们需要从S.dll 的程序集引用切换到使用 nuget - 以获得S依赖项。

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.然而,为我们的共享解决方案项目使用 nuget 包并在后端项目中开发将成为一场噩梦,因为我们需要在每次S更改时创建一个新的 nuget 包(并发布它),并且需要增加包引用中的版本号一直在后端项目中。 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).此外,这将变得非常不切实际,因为我们的开发人员也在使用各种 git 功能分支(考虑版本冲突;必须发布未完成的包,并且可能使用版本后缀“alpha_”+{branchName} 来区分此版本来自的分支) .

How to develop on localhost?如何在本地主机上开发? Is there a way to avoid nuget (but getting its dependencies resolved correctly!)?有没有办法避免 nuget(但正确解析其依赖项!)?

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)我已经在阅读有关通过在 csproj 文件中使用条件对 CI 构建使用 nuget 包引用时为本地开发提供程序集引用的内容(但是,这在 VS2017 中也不能很好地工作;这也无法解决我们编写的依赖问题的问题)以上在本地主机上)

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. PS 我不想将S的依赖项包含到每个引用S的项目中,也就是在那里使用包引用。 This would not be a solution and becomes more cumbersome when S might get new dependencies for whatever reason.这不会是一个解决方案,并且当S可能出于任何原因获得新的依赖项时会变得更加麻烦。

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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