错误MSB3644:找不到.NETFramework的参考程序集,版本=v4.7.2

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

在我的 gitlab-ci.yml 中,我想要一个 C# 项目由 sonarqube(社区版)检查 (https://i.stack.imgur.com/TKTTh.png)

在构建阶段我收到此错误: (https://i.stack.imgur.com/LTIB3.png)

.csproj 文件明确要求 .Net Framework 版本 4.7.2。

由于我知之甚少,我想知道是否可以在 gitlab-ci.yml 中添加一行来在构建过程之前安装缺少的版本,就像我在第 17 行中尝试的那样,但失败了。

第二个想法是我要分析的项目太旧了,.NetFramework v.4.7.2 已过时/不包含在 .Net SDK v.8 中。

无论如何,我的问题是,在这个阶段需要做什么才能继续并能够分析 C# 项目。

我有大约1个月的经验。 gitlab 和 sonarqube 作为 docker 容器托管在本地服务器上。

我做了一些研究,结果导致了困惑。

编辑:23.10.19; 12:00 更新了 gitlab.yml:https://i.stack.imgur.com/iS5iT.png

编辑:23.1023; 12:21 添加了我用于该项目的 .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>{BEBB4651-1EE2-415E-BEA5-3FC0E271BBFC}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <RootNamespace>HT10KokoCom</RootNamespace>
    <AssemblyName>HT10KokoCom</AssemblyName>
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <WarningLevel>4</WarningLevel>
    <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>
  <PropertyGroup>
    <ApplicationIcon>htx 32x32.ico</ApplicationIcon>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Management" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xaml">
      <RequiredTargetFramework>4.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
  </ItemGroup>
  <ItemGroup>
    <ApplicationDefinition Include="App.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </ApplicationDefinition>
    <Page Include="MainWindow.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </Page>
    <Compile Include="AES128Service.cs" />
    <Compile Include="App.xaml.cs">
      <DependentUpon>App.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="CassemblyInfo.cs" />
    <Compile Include="CcalibData.cs" />
    <Compile Include="Ccsv.cs" />
    <Compile Include="CgrafElements.cs" />
    <Compile Include="Ckoko1.cs" />
    <Compile Include="ClassCommand.cs" />
    <Compile Include="CprotokollHtxKoko.cs" />
    <Compile Include="MainWindow.xaml.cs">
      <DependentUpon>MainWindow.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Properties\AssemblyInfo.cs">
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <ItemGroup>
    <Resource Include="htx 32x32.ico" />
  </ItemGroup>
  <ItemGroup>
    <Resource Include="htx2 32x32.png" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
c# .net docker sonarqube gitlab-ci
1个回答
0
投票

.NET SDK 映像不支持 .NET Framework 4.7.2,您需要 .NET Framework SDK 映像。在您的情况下,您至少需要

mcr.microsoft.com/dotnet/framework/sdk:4.7.2
,尽管 4.8 和 4.8.1 标签也支持构建该 .NET 版本。我个人推荐使用
mcr.microsoft.com/dotnet/framework/sdk:4.8
,因为它在更多版本的 Windows 主机上受支持。

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