【问题标题】:SonarQube support for .sqlproj and .dtprojSonarQube 支持 .sqlproj 和 .dtproj
【发布时间】:2017-01-20 18:33:54
【问题描述】:

我们有一个有效的 SonarQube 6.0 版安装,它正在检查许多 C# 项目,例如扩展名为 .csproj 的那些。如果 .csproj 包含 sql 文件,则将检查此文件。

在一个新的解决方案中,我们混合了 .csproj、.dtproj 和 .sqlproj 项目。 SonarQube 仅检查 .csproj 项目,尽管大部分 .sqlproj 由 sql 文件组成。

SonarQube 可以检查 .sqlproj 和/或 .dtproj 中的文件吗?

【问题讨论】:

    标签: .net sql-server visual-studio ssis sonarqube


    【解决方案1】:

    为了解决这个问题,我创建了一个虚拟 csproj,它只存在于使用 ItemGroup 中的通配符从所有数据库项目中提取所有 sql 文件,例如

    <ItemGroup> <Content Include="**\*.sql" /> </ItemGroup>

    在解决方案中包含此项目并将其传递给 Sonar 意味着检查项目中的 sql 文件。

    完整的 csproj 是:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="14.0" DefaultTargets="Build" 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>{A1DE4897-3BBB-4F67-8D97-662793603C18}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>Dummy.Sonar</RootNamespace>
        <AssemblyName>Dummy.Sonar</AssemblyName>
        <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <SccProjectName>SAK</SccProjectName>
        <SccLocalPath>SAK</SccLocalPath>
        <SccAuxPath>SAK</SccAuxPath>
        <SccProvider>SAK</SccProvider>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <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' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
        <CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
        <NoWarn>2210</NoWarn>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="System" />
        <Reference Include="System.Core" />
        <Reference Include="System.Xml.Linq" />
        <Reference Include="System.Data.DataSetExtensions" />
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System.Data" />
        <Reference Include="System.Net.Http" />
        <Reference Include="System.Xml" />
      </ItemGroup>
      <ItemGroup>
        <Folder Include="Properties\" />
      </ItemGroup>
      <ItemGroup>
        <Content Include="**\*.sql" />
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
    </Project>
    

    【讨论】:

    • 您介意在此处粘贴虚拟 csproj 的内容吗?
    • 嗨@matt,感谢您的解决,但在这里我怀疑是否存在相同sln的其他一些.csproj中的任何sql文件将被分析两次,对吗?...根据解决方法.如有错误请指正...
    【解决方案2】:

    SonarQube Scanner for MSBuild目前不支持 SQL 服务器项目。您可以通过票证 SONARMSBRU-243 跟踪进度。

    【讨论】:

    • 感谢您的链接。我会尝试在短期内想出一个解决方法。
    猜你喜欢
    • 2018-01-02
    • 2015-10-23
    • 1970-01-01
    • 2017-02-13
    • 2015-07-11
    • 2017-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多