简体   繁体   English

FsUnit,NUnit在F#项目中引用

[英]FsUnit, NUnit references in an F# project

I have a solution in Visual Studio 2012. It includes two projects for tests, one in F# and one in C#. 我在Visual Studio 2012中有一个解决方案。它包括两个测试项目,一个在F#中,一个在C#中。 I have installed NUnit and FsUnit as Nuget packages. 我已经将NUnit和FsUnit安装为Nuget包。 After the installation, the references to these assemblies point to the dll 's found in the \\packages\\ folder inside my solution. 安装之后,对这些程序集的引用指向我的解决方案内的\\packages\\文件夹中的dll After I compile the solution, the references change in the F# project and point to the NUnit installed in my C:\\Program Files (x86)\\ folder and the \\bin\\Debug\\FsUnit.NUnit.dll in my F# project. 编译解决方案后,引用在F#项目中发生更改,并指向我的C:\\Program Files (x86)\\文件夹中安装的NUnit和我的F#项目中的\\bin\\Debug\\FsUnit.NUnit.dll In the C# project the references keep pointing to the packages folder. 在C#项目中,引用继续指向packages文件夹。

The project builds in Visual Studio and the tests run fine. 该项目在Visual Studio中构建,测试运行良好。 When I build it in TeamCity it fails as it cannot find NUnit and FsUnit in the F# project. 当我在TeamCity中构建它时失败,因为它在F#项目中找不到NUnit和FsUnit。

Any ideas why the reference change when I compile? 我编译时为什么引用会改变的想法?

Moreover, why the properties of a reference in an F# project contain much less information compared to the ones in a C# project? 此外,为什么F#项目中的引用属性与C#项目中的引用属性相比包含的信息要少得多?

To close this question, and for future reference, the references in the .fsproj were originally 要关闭此问题以及将来参考, .fsproj中的引用最初是

<Reference Include="FsUnit.NUnit, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null">
  <Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
  <Private>True</Private>
</Reference>

Following Brian's advice, I replaced them with the ones from the .csproj below 按照Brian的建议,我将它们替换为下面的.csproj中的那些

<Reference Include="FsUnit.NUnit, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\FsUnit.1.1.0.0\Lib\Net40\FsUnit.NUnit.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
  <HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
</Reference>

This seems to be a bug in NuGet that affects only F# projects, and then only in VS 2012. You'll notice that if you ever use NuGet to upgrade to a newer version of NUnit or FSUnit, your HintPaths will once again be stripped from the .fsproj file. 这似乎是NuGet中的一个错误,只影响F#项目,然后仅在VS 2012中。您会注意到如果您使用NuGet升级到更新版本的NUnit或FSUnit,您的HintPath将再次被剥离.fsproj文件。

http://nuget.codeplex.com/workitem/2149 http://nuget.codeplex.com/workitem/2149

Please vote for that issue so it hopefully gets some attention before the final release of VS 2012! 请投票支持该问题,以便在VS 2012最终发布之前获得一些关注!

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

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