简体   繁体   English

Nuget更新包中断参考条件

[英]Nuget Update Package breaks Reference conditional

Some private Nuget packages in my solution are referenced by their local dlls in Debug and referenced as a nuget package in Release. 我的解决方案中的某些私有Nuget程序包在Debug中由其本地dll引用,并在Release中作为nuget程序包引用。

This is my Web.csproj: 这是我的Web.csproj:

<Choose>
<When Condition="'$(Configuration)' == 'Release'">
  <Reference Include="CustomPackage, Version=1.0.0.0, Culture=neutral">
    <HintPath>..\packages\CustomPackage.1.0.0\lib\net461\CustomPackage.dll</HintPath>
    <Private>True</Private>
  </Reference>
</When>
<Otherwise>
  <Reference Include="CustomPackage, Version=1.0.0.0, Culture=neutral">
    <HintPath >..\..\CustomPackage\bin\$(Configuration)\CustomPackage.dll</HintPath>
    <Private>True</Private>
  </Reference>
</Otherwise>
</Choose>

After CustomPackage gets published and updated to 1.0.1 , I update that package in the Nuget Package Manager for my Solution. CustomPackage发布并更新为1.0.1 ,我在Nuget软件包管理器中为我的解决方案更新了该软件包。

Problem: Nuget will then completely remove the first reference and place the updated reference outside of the conditional during the update. 问题: Nuget然后将完全删除第一个引用,并将更新后的引用放在更新过程中的条件之外。

I found Nuget Reference Switcher which I thought would be my solution by that wants you to add all projects you reference locally into the Solution which doesn't not work with my team and we need to reference just the dll. 我找到了Nuget Reference Switcher ,我认为这是我的解决方案,它希望您将本地引用的所有项目添加到该解决方案中,该项目不适用于我的团队,我们只需要引用dll。 A GitHub Issue was filed with others having the same problem. GitHub问题已提交给其他有相同问题的人。

Is there any other approach besides this conditional? 除了此条件外,还有其他方法吗?

Can I apply a transform to my Web.csproj with a Web.Debug.csproj during build? 我可以在构建过程中使用Web.Debug.csproj将转换应用于Web.csproj吗?

Thanks, Alex 谢谢,亚历克斯

When we upgrade a NuGet package for our project, it will execute the Uninstall and Reinstall process which will modify our .csproj file to add the references into our project. 当我们为项目升级NuGet程序包时,它将执行“卸载并重新安装”过程,该过程将修改.csproj文件,以将引用添加到我们的项目中。

And we could not change our .csproj file during build, because the build process need to build your project based on the settings in .csproj. 而且我们无法在构建过程中更改.csproj文件,因为构建过程需要基于.csproj中的设置来构建项目。

All above processes are default action for nuget and project in Visual Studio. 以上所有过程都是Visual Studio中nuget和project的默认操作。

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

相关问题 安装NuGet软件包Owin,获取参考错误 - Installing NuGet package Owin, get reference error NuGet项目&gt;添加库包参考未出现 - NuGet Project > Add Library Package Reference not appearing 如何使用MSDeploy更新服务器中的Nuget程序包 - How to update the Nuget Package in the Server using MSDeploy 我是否应该将ASP.NET MVC引用为NuGet包? - Should I reference ASP.NET MVC as NuGet package? 使用 nuget package 代替项目参考 Visual Studio - Use nuget package instead of project reference Visual studio 来自Nuget包的Font Awesome和来自BundleConfig.cs的引用 - Font Awesome from Nuget package and reference from BundleConfig.cs Elmah nuget软件包不会更新web.config - Elmah nuget package doesn't update web.config Nuget Update-Package错误地更新了程序集绑定重定向 - Nuget Update-Package incorrectly updating assembly binding redirects 如何在未安装 Nuget 或 Visual Studio 的 Web 服务器上安装、更新、注册 Nuget package? - How do I Install, Update, Register a Nuget package on the Web Server that does not have Nuget or Visual Studio installed? 更新程序包管理器控制台,以便在启用NuGet程序包还原后可以使用更新数据库 - Update the Package Manager console so Update-Database is available after Enable NuGet Package Restore
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM