Fortify build for .NET Core 项目

Fortify build for .NET Core Projects

我正在尝试 运行 按照 powerShell 脚本使用 Fortify 扫描我的解决方案(.NET Core 2.0):

$SolutionFilePath = "C:\Repositories\MyProject"
$SolutionFileName = "MyProjectToTest"
$SSCFPRFileName = "MyProjectToTest.fpr"
$BuildIdName = "MyProjectToTest"


$path = "D:\Fortify"
If(!(test-path $path))
{
   New-Item -ItemType Directory -Force -Path $path
}

cd \
cd "C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\MSBuild\Current\Bin"

sourceanalyzer -b $BuildIdName -clean
sourceanalyzer -b $BuildIdName msbuild "$SolutionFilePath$SolutionFileName.sln" 
sourceanalyzer -b $BuildIdName -scan -f "$path$SSCFPRFileName"

exit 0

在我的本地机器上一切正常。

但是,当我在 TeamCity(TeamCity Enterprise 2018.2.1(build 61078))中尝试在服务器中 运行 它作为构建步骤时,我收到了一个错误:

Microsoft (R) Build Engine version 16.0.461+g6ff56ef63c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1021: Cannot create an instance of the logger. Could not load file or assembly 'Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Switch: C:\Program Files\HPE_Security\Fortify_SCA_and_Apps_17.20\Core\lib\FortifyMSBuildTouchless.dll

我在本地和服务器上使用相同版本的 Fortify(Fortify Static Code Analyzer 17.20.0183(使用 JRE 1.8.0_144) ).

在服务器和本地机器上我都安装了Build Tools for Visual Studio 2019和.Net core SDK。

我尝试使用不同版本的 MsBuild(14, 15, 16) 和 dotnet.exe 以及 devenv.exe 并安装了 PowerShell Core。我得到了同样的错误。

我也可以 运行 .NETFramework 项目的同一服务器中的脚本成功,唯一的变化是我使用了不同的路径:

cd "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"

似乎 Fortify 17.20 不支持 .NETCore 2.X,当我添加

-dotnet-core-version 2.0

我收到一个错误(在本地和服务器中):

[error]: Invalid parameter 2.0 for command line argument -dotnet-core-version

但是 1.X 就可以了,那么同一个版本的 fortify 怎么可能在本地工作正常而在服务器上却不行呢?

.NETCore 项目有什么问题?有什么想法吗?

经过一番搜索,我找到了这个,它对我来说很好用:

$SolutionFilePath = "C:\Repositories\MyProject"
$SolutionFileName = "MyProjectToTest"
$SSCFPRFileName = "MyProjectToTest.fpr"
$BuildIdName = "MyProjectToTest"


$path = "D:\Fortify"
If(!(test-path $path))
{
   New-Item -ItemType Directory -Force -Path $path
}

cd \
cd "$SolutionFilePath"

sourceanalyzer -b $BuildIdName -clean
sourceanalyzer -b $BuildIdName -libdirs **/* **/* 
sourceanalyzer -b $BuildIdName -scan -f "$path$SSCFPRFileName"

exit 0

没有 msbuild 没有其他命令只是导航到解决方案文件夹并且 运行 它没有任何额外的命令。