我有这个F#项目Rm.Accounting.Domain
包含以下文件(并按此顺序):
Model.fs
:module Rm.Accounting.Domain.Model
Commands.fs
:module Rm.Accounting.Domain.Commands
Events.fs
:module Rm.Accounting.Domain.Events
最后一个引起问题的Behaviour.fs
:
module Rm.Accounting.Domain.Behaviour
open Rm.Accounting.Domain.Commands
open Rm.Accounting.Domain.Events
open Rm.Accounting.Infrastructure
let a = 42
这会导致两个错误:
Behaviour.fs(3, 20): [FS0039] The namespace 'Domain' is not defined.
-> open Rm.Accounting.Domain.Commands
Behaviour.fs(4, 20): [FS0039] The namespace 'Domain' is not defined.
-> open Rm.Accounting.Domain.Events
如果没有该项目可以编译的文件Behaviour.fs
,我不确定为什么这两次导入会引起一些麻烦。
答案 0 :(得分:1)
感谢评论,尽管出于某些原因,尽管在Rider中对文件进行了重新排序,fsproj
并没有得到正确的更新。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Behaviour.fs" />
<Compile Include="Model.fs" />
<Compile Include="Commands.fs" />
<Compile Include="Events.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rm.Accounting.Infrastructure\Rm.Accounting.Infrastructure.fsproj" />
</ItemGroup>
</Project>
重新组织fsproj,做到了:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Model.fs" />
<Compile Include="Commands.fs" />
<Compile Include="Events.fs" />
<Compile Include="Behaviour.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rm.Accounting.Infrastructure\Rm.Accounting.Infrastructure.fsproj" />
</ItemGroup>
</Project>