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

问题描述 投票:0回答:1

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

当我用 C# 编写相同的程序时,构建目录是干净的,并且仅包含构建的文件以及我告诉它包含的引用程序集(使用“复制本地”)。

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

这只是 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>
c# .net f# msbuild
1个回答
0
投票

您可以将此属性添加到项目中以获得旧行为

    <DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>

有关更多信息,请参阅此答案:https://stackoverflow.com/a/60852224/7392598

© www.soinside.com 2019 - 2024. All rights reserved.