我已经将目前针对VS2010中的。net 4.0的解决方案迁移到VS2012,现在我想将其重新定位到。net 4.5
我不确定的是NuGet包。例如,我在VS2010中从EF4更新的EF5实际上是EF 4.4,你可以在这里看到:
<Reference Include="EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>
我还可以在包装中看到以下内容。项目的配置:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net40" />
</packages>
所以我的问题是:
将所有NuGet包重新定位到。net 4.0的最佳实践是什么?
NuGet 2.1提供了一个特性,使这个过程简单得多:只需在包管理器控制台中执行update-package -重装-ignoreDependencies即可。
NuGet 2.0不能很好地处理应用程序的重新定位。为了改变你的包的目标框架,你必须卸载和重新安装包(记下你已经安装的包,这样你就可以重新安装它们)。
需要卸载和重装软件包的原因如下:
When installing a package, we determine the target framework of your project
We then match that up with the package contents, finding the appropriate \lib\ folder (and \content\ folder)
Assembly references are added with Hint Paths that point to the package's \lib\ folder, with the right subfolder (\lib\net40 for example)
Content files are copied from the packages \content\ folder, with the right subfolder (\content\net40 for example)
We record the targetFramework used to install the package within the packages.config file
After you change your project's target framework, the Hint Paths still point to net40
When you uninstall packages, we check the targetFramework that was recorded in packages.config to see what target framework's libs/content to remove from your project
When you reinstall the package, we detect your updated target framework and reference/copy the right libs/content