【发布时间】:2017-06-27 04:22:48
【问题描述】:
编辑:已经解决了问题!请参阅下面的答案。
我创建的 nuget 包有一个奇怪的问题。 我已经创建了几个nuget包,以前从来没有遇到过这个问题,但是现在突然安装新包时,它会产生一个无效的web.config文件。
nuspec 文件与其他一些(工作的)项目几乎完全相同。我添加了安装脚本和一些特殊内容,并在元数据部分设置了依赖关系:
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Kooco.com Ltd</authors>
<owners>$author$</owners>
<description>Server-Project Template for use with the Kooco.Framework</description>
<releaseNotes>Pre-Alpha Release</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>Maxima Kooco WebProjects</tags>
<dependencies>
<dependency id="Newtonsoft.Json" version="10.0" />
<dependency id="AutoMapper" version="6.0" />
<dependency id="WebActivatorEx" version="2.2" />
<dependency id="Kooco.Framework" version="$version$" />
</dependencies>
<references>
</references>
</metadata>
<files>
<file src="install.ps1" target="tools" />
<file src="NugetOverwriteContents\**\*.*" target="tools\OverwriteContents" />
<file src="NugetNoOverwriteContents\**\*.*" target="tools\NugetNoOverwriteContents" />
</files>
</package>
依赖项与其他(工作)包中的依赖项完全相同。
但由于某些原因,在安装包时,nuget 会产生以下 web.config 部分,这会导致应用程序中的错误,因为非关闭标签:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" /><assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /><assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /></dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
在安装 nuget 包之前:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" /><assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /></dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
我不进行自定义配置转换。 我有一个安装脚本,但这个脚本不是问题,我也尝试在没有安装脚本的情况下安装,但遇到了同样的问题。
目标项目是一个空的 ASP.Net Web 应用程序,我在其中使用“空”模板并激活了“MVC”和“WebAPI”。
我的 nuget 包管理器版本是 3.5.0.1484。启用自动更新。 我正在使用 Visual Studio 2015 社区版。我的系统是 Windows 10。
有人知道是什么导致了这个问题吗?
【问题讨论】:
标签: visual-studio nuget nuget-package