Natalie Perret
Natalie Perret

Reputation: 8997

F#: the namespace is not defined

I have this F# project Rm.Accounting.Domain with the following files (and in that order):

and the last one causing problems Behaviour.fs:

module Rm.Accounting.Domain.Behaviour

open Rm.Accounting.Domain.Commands
open Rm.Accounting.Domain.Events
open Rm.Accounting.Infrastructure

let a = 42

Which leads to two errors:

Without that file Behaviour.fs the project can compile, I am not sure to understand why those two imports cause some troubles.

Upvotes: 6

Views: 2425

Answers (1)

Natalie Perret
Natalie Perret

Reputation: 8997

Thanks to the comments, it seems that for some reasons despite reordering files in Rider, the fsproj didn't really get updated right.

<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>

enter image description here

Re-organising the fsproj, did the trick:

<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>

Upvotes: 7

Related Questions