.net core 加强.NET核心项目的构建
我正在尝试运行以下powerShell脚本,以便使用Fortify扫描我的解决方案(.NET Core 2.0):.net core 加强.NET核心项目的构建,.net-core,teamcity,fortify,.net Core,Teamcity,Fortify,我正在尝试运行以下powerShell脚本,以便使用Fortify扫描我的解决方案(.NET Core 2.0): $SolutionFilePath = "C:\Repositories\MyProject" $SolutionFileName = "MyProjectToTest" $SSCFPRFileName = "MyProjectToTest.fpr" $BuildIdName = "MyProjectToTest" $path = "D:\Fortify" If(!(test-
$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 Studio\2019\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 Enterprise 2018.2.1(构建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静态代码分析器17.20.0183(使用JRE 1.8.0144)
)
在服务器和本地机器中,我安装了.Net核心SDK
我尝试了不同版本的MsBuild(14、15、16)和dotnet.exe
和devenv.exe
,并安装了PowerShell Core。我也犯了同样的错误
我还可以在同一服务器上为.NETFramework项目成功运行脚本,唯一的变化是我使用了不同的路径:
cd "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
当我添加
-dotnet-core-version 2.0
我收到一个错误(在本地和服务器中):
但是使用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没有其他命令只需导航到解决方案文件夹并在没有任何额外命令的情况下运行它
$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