F#和#x27;s脚手架和FsUnit/FsCheck

F#和#x27;s脚手架和FsUnit/FsCheck,f#,mono,F#,Mono,我正在努力使用ProjectScaffold在Linux上开始使用F#。 具体来说:我无法让项目与FsUnit/FsCheck/xunit一起工作。我 有了F#3.1和mono 3.12.1,我现在使用的是Linux(Ubuntu)x64 我以以下方式开始“我的项目”: 然后我在“src/MyProject/Library.fs”中添加了一些代码: 然后对“tests/MyProject.tests/tests.fs”进行两个测试: 然后: …它失败了,因为NUnit在某处被引用,所以我删除了t

我正在努力使用ProjectScaffold在Linux上开始使用F#。 具体来说:我无法让项目与FsUnit/FsCheck/xunit一起工作。我 有了F#3.1和mono 3.12.1,我现在使用的是Linux(Ubuntu)x64

我以以下方式开始“我的项目”:

然后我在“src/MyProject/Library.fs”中添加了一些代码:

然后对“tests/MyProject.tests/tests.fs”进行两个测试:

然后:

…它失败了,因为NUnit在某处被引用,所以我删除了tests/MyProject.tests/paket.references和

$ mono .paket/paket.exe install
有效,但是

$ ./build.sh
失败,至少找不到对FsCheck等的引用。因此我假设需要手动添加引用,因此tests/MyProject.tests/paket.references现在为:

FsCheck
FsCheck.Xunit
FsUnit.xUnit
xunit

…build build.sh再次失败:它找不到FsCheck。我在paket文档中找不到如何添加本地依赖项(MyProject.Tests应该引用MyProject),这可能是自动完成的。

我遇到了这个问题,花了一段时间才找到解决方法。对于Tests目录中的项目文件,我必须更改以下内容:

<Reference Include="FsUnit.NUnit">
    <HintPath>..\..\packages\FsUnit.1.3.0.1\Lib\Net40\FsUnit.NUnit.dll</HintPath>
    <Private>True</Private>
</Reference>

一旦我做了这些更改,这个项目在VisualStudio和mono下都可以正常工作

我不太确定,我理解你:你有两个fsproj文件吗,一个用于生产代码,一个用于单元测试?你在fsproj中引用FsCheck吗


另外,我还记得一个问题,如果您针对较旧版本的.net编译并引用针对较新版本的.net编译的程序集,它的行为将如同没有引用一样。

感谢您的回答,但这似乎不是问题所在。项目文件确实有正确的dll引用,我不知道为什么我会得到“名称空间或模块'FsCheck'未定义”。决定是否要使用NuGet(并从VS中添加引用)或paket,不要像这样混合使用它们!保留您的paket.references,删除所有nuget软件包和引用(从visual studio中),然后运行
paket安装
(这将为您重新添加所有引用)。paket不会触及项目引用,所以只需像通常通过VisualStudio那样添加它们。
source https://nuget.org/api/v2

nuget FSharp.Formatting 2.8.0
nuget FSharpVSPowerTools.Core 1.7.0
nuget FAKE
nuget FsCheck 1.0.4
nuget FsCheck.Xunit 1.0.4
nuget FsUnit.xUnit 1.3.0.1
nuget xunit 1.9.2
nuget SourceLink.Fake

github fsharp/FAKE modules/Octokit/Octokit.fsx
$ mono .paket/paket.exe install
$ mono .paket/paket.exe install
$ ./build.sh
FsCheck
FsCheck.Xunit
FsUnit.xUnit
xunit
<Reference Include="FsUnit.NUnit">
    <HintPath>..\..\packages\FsUnit.1.3.0.1\Lib\Net40\FsUnit.NUnit.dll</HintPath>
    <Private>True</Private>
</Reference>
<Reference Include="FsUnit.NUnit">
    <HintPath>..\..\packages\FsUnit\Lib\Net40\FsUnit.NUnit.dll</HintPath>
    <Private>True</Private>
</Reference>
<Reference Include="nunit.framework">
  <HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="nunit.framework">
  <HintPath>..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
  <Private>True</Private>
</Reference>
#!/bin/bash
if test "$OS" = "Windows_NT"
then
  # no changes in here
else
  # fix test fsproj file
  mv tests/ProjectName.Tests/ProjectName.Tests.fsproj tests/ProjectName.Tests/ProjectName.Tests.fsproj.vs
  mv tests/ProjectName.Tests/ProjectName.Tests.fsproj.mono tests/ProjectName.Tests/ProjectName.Tests.fsproj  

  # leave the script logic for mono in place

  # put project files back to avoid git noticing the swap
  mv tests/ProjectName.Tests/ProjectName.Tests.fsproj tests/ProjectName.Tests/ProjectName.Tests.fsproj.mono
  mv tests/ProjectName.Tests/ProjectName.Tests.fsproj.vs tests/ProjectName.Tests/ProjectName.Tests.fsproj

fi