阻止 F# 添加间接引用的程序集。

3

我正在使用 VS 2022,当我创建一个 F# 项目和解决方案时,在构建解决方案时,它会将所有间接引用的程序集从另一个程序集转储到 bin 目录中。

enter image description here

当我用C#编写相同的程序时,生成目录是干净的,只包含构建文件以及我告诉它要包含的引用程序集(使用Copy Local)。

enter image description here

引用了所有其他程序集的程序集在两个项目中其私有属性都标记为False,但F#仍然会将所有内容拖入其中。

enter image description here

这只是F#如何构建和引用C#库的问题吗?

我尝试修改了 Private 属性,并寻找其他可能适用的配置项。我将要添加到目录中的 DLL 添加到项目文件中,希望它不会复制它,但它仍然会复制。

以下是 .csproj 文件。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{B9485712-4A8F-4894-8268-003BC72149C3}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>ConnectTest</RootNamespace>
    <AssemblyName>ConnectTest</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <Deterministic>true</Deterministic>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="EllieMae.Encompass.AsmResolver">
      <HintPath>C:\Program Files (x86)\Encompass\EllieMae.Encompass.AsmResolver.dll</HintPath>
    </Reference>
    <Reference Include="EllieMae.Encompass.Runtime">
      <HintPath>C:\Program Files (x86)\Encompass\EllieMae.Encompass.Runtime.dll</HintPath>
    </Reference>
    <Reference Include="EncompassObjects">
      <HintPath>C:\Program Files (x86)\Encompass\EncompassObjects.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

这是 .fsproj 文件。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net48</TargetFramework> 

    <WarnOn>3390;$(WarnOn)</WarnOn>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="ClientServer">
      <HintPath>C:\Program Files (x86)\Encompass\ClientServer.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="EllieMae.Encompass.AsmResolver">
      <HintPath>C:\Program Files (x86)\Encompass\EllieMae.Encompass.AsmResolver.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="EllieMae.Encompass.Runtime">
      <HintPath>C:\Program Files (x86)\Encompass\EllieMae.Encompass.Runtime.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="EncompassObjects">
      <HintPath>C:\Program Files (x86)\Encompass\EncompassObjects.dll</HintPath>
      <Private>True</Private>
    </Reference>
  </ItemGroup>
</Project>

1
你能展示完整的 .csrpoj.fsproj 吗? - undefined
@JL0PD项目文件已添加。如果您需要其他任何帮助,请告诉我。非常感谢您能提供的任何帮助。 - undefined
2
C#使用传统的项目格式,而F#版本使用sdk-style格式,它们具有不同的行为。如果你将C#项目转换为较新的格式,可能会得到与F#项目相同的行为。然后问题就是如何在较新的项目格式中实现所需的目标,对此我没有答案。 - undefined
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接