我无法理解Visual Studio 2019中的警告和错误。从Visual Studio 2017升级后,似乎所有对项目包的引用都不再有效。当我编译解决方案时,有日志的初始行。
1>------ Build started: Project: ClientServerUpload, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Text.Encoding.CodePages". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3243: No way to resolve conflict between "System.Text.Encoding.CodePages, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Text.Encoding.CodePages". Choosing "System.Text.Encoding.CodePages, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1> No way to resolve conflict between "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1> No way to resolve conflict between "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1> Consider app.config remapping of assembly "FSharp.Core, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.4.3.0" [] to Version "4.7.0.0" [\\mypath\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll] to solve conflict and get rid of warning.在上面的代码之后还有很多其他的代码行,但无论如何我看不出哪里出了问题。例如,我选择了第一条消息,关于"System.Text.Encoding.CodePages"。有一个警告说是"Could not locate the assembly",另一个是关于Version=4.1.3.0和一个没有版本的引用之间的冲突。但是它从哪里来看待Version=4.1.3.0呢?在pacakge.config中有一行:
<package id="System.Text.Encoding.CodePages" version="4.7.0" targetFramework="net461" />如果我编辑.proj文件,我会看到:
<Reference Include="System.Text.Encoding.CodePages"> <HintPath>..\packages\System.Text.Encoding.CodePages.4.7.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>HintPath确实就在那里。对所有其他消息和错误也有类似的怀疑。再举一个例子,为什么要搜索FSharp.Core, Version=4.4.1.0?再一次,我有
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll</HintPath>
</Reference>在项目文件和packages.config中
<package id="FSharp.Core" version="4.7.0" targetFramework="net461" />我所知道的所有配置在我看来都是正确的,整个解决方案在Visual Studio 2017中完全没有问题。该项目是使用WebSharper模板构建的,我不知道这是否/如何相关,但是在升级到Visual Studio2019之后,我也重新安装了VSIX,我没有收到任何错误。除了删除和恢复所有软件包、查看.proj文件、清理和重建解决方案之外,我还有什么其他选择?我还应该看些什么呢?我知道我可以向Web.config添加重映射,但我不认为这是解决方案(甚至不是变通方法)。为了给你提供信息,几个小时后,我设法得到了一个带有许多(奇怪的)重新映射行的发行版,并通过手动(!)将一些文件(包括FSharp.Core)从软件包复制到bin文件夹,这显然不是一种可接受的继续操作方式。
发布于 2020-02-11 17:31:13
当我将一个F#项目从VS2015升级到2017年时,我似乎想起了类似的事情。
解决方案是在项目属性中更新F#运行时(FSharp.Core.dll)的版本。
查看.NET Core3.0 F#项目的.fsproj:实际上并没有列出F#运行时,因此必须是一个隐式依赖:也许删除它也可以。
发布于 2020-02-11 17:43:43
第0步
我已经恢复了我的项目的旧提交,以更好地描述原始情况并跟踪解决它的所有步骤。在接下来的两个操作之前,我不得不从FSharp.Core 4.6升级到4.7,因为一个特定于WebSharper的问题:没有生成脚本。
第一步
我不得不编辑.proj文件来删除一些参考线,有点重复。下面是FSharp.Core的一个示例,但我对其他许多示例也做了同样的事情(我不知道是什么导致了这个问题,但删除这些行似乎已经帮我解决了这个问题)
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="FSharp.Core" />在上面的例子中,我删除了最后一行(以及在包含相同包版本的标签下没有版本引用的所有其他类似行)。
第二步
然后,我将Visual Studio输出中的所有<dependentAssembly>复制并粘贴到Web.config。再一次,我不明白它们比Visual Studio 2017所需要的多得多,但这两个操作显然解决了我的问题。
https://stackoverflow.com/questions/60165181
复制相似问题