120 lines
4.8 KiB
Batchfile

set STRONG_NAME_SIGNING_TOOL="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe"
set STRONG_NAME_KEY_FILE="AMT_SDK_STRONG_NAME_KEY.snk"
@echo off
set COMPILE_MODE=Release
shift
if "%0"=="-d" set COMPILE_MODE=Debug
echo on
..\..\..\..\Windows\Intel_AMT\Tools\vswhere.exe -legacy -latest -property installationPath > temp.txt
set /p tool_path=<temp.txt
del temp.txt
call "%tool_path%\Common7\Tools\VsDevCmd.bat"
ATTRIB -R "WsmanLib.csproj"
py ..\..\..\remove_repo_compilation.py "WsmanLib.csproj"
rem copy SecureStringExtensions
copy ..\..\Utils\C#\SecureStringExtensions.cs .
rem copy src folder
mkdir ..\..\Bin\WSManLib\Src
xcopy /s /y ..\WsmanLib\** ..\..\Bin\WSManLib\Src\
rem remove files that are excluded in the project
del .\..\..\Bin\WSManLib\Src\Mei\HostSetupService.cs
del .\..\..\Bin\WSManLib\Src\Mei\HttpSetupRequest.cs
del .\..\..\Bin\WSManLib\Src\Mei\IMeSetupInfo.cs
del .\..\..\Bin\WSManLib\Src\Mei\ISetupParameters.cs
del .\..\..\Bin\WSManLib\Src\Mei\MePing.cs
del .\..\..\Bin\WSManLib\Src\Mei\MeProxy.cs
del .\..\..\Bin\WSManLib\Src\Mei\MeSetupService.cs
del .\..\..\Bin\WSManLib\Src\Mei\SetupProxy.cs
del .\..\..\Bin\WSManLib\Src\Redirection\TerminalProcess.cs
del .\..\..\Bin\WSManLib\Src\Wsman\AmtRequest.cs
del .\..\..\Bin\WSManLib\Src\Wsman\"WsmanConnection new version.cs"
rem remove Readme and Release-notes from src
del .\..\..\Bin\WSManLib\Src\"WsmanLib Readme.txt"
del .\..\..\Bin\WSManLib\Src\"WsmanLib Release-notes.txt"
mkdir ..\..\..\Intel_AMT\Bin\Ws-Management\WSManLib
mkdir ..\..\..\Intel_AMT\Bin\Ws-Management\WSManLib\StrongNamed
mkdir ..\..\Bin\WSManLib\Bin
mkdir ..\..\Bin\WSManLib\Bin\StrongNamed
rem change the version
ATTRIB -R "Properties\AssemblyInfo.cs"
%BuildToolsDir%Scripting\Perl.5.6.0\bin\perl.exe updatebuild.pl %BUILD_VERSION% Properties\AssemblyInfo.cs
rem Dotnet Restore
echo "Run Dotnet Restore"
dotnet restore "WsmanLib.csproj"
msbuild "WsmanLib.csproj" /t:Rebuild /property:Configuration=%COMPILE_MODE% /p:UseSharedCompilation=false /p:ProduceReferenceAssembly=false -fileLogger -fileLoggerParameters:logfile=..\..\helper.txt;verbosity=diagnostic
if errorlevel 1 goto BuildFailed
echo WsmanLib - %COMPILE_MODE% > ..\..\log.txt
echo WsmanLib - %COMPILE_MODE%
REM Sign files
if not defined KW_SCAN (
C:\Windows\System32\findstr /C:"WsmanLib -" ..\..\helper.txt >> ..\..\log.txt
signtool.exe sign /v /sha1 %CERT_THUMBPRINT% /fd sha256 /tr http://timestamp.comodoca.com/rfc3161 /td sha256 bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll
if errorlevel 1 goto SignFailed
signtool.exe verify /v /debug /pa bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll
if errorlevel 1 goto SignFailed
)
echo ==================================================== >> ..\..\log.txt
copy bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll "..\..\..\Intel_AMT\Bin\Ws-Management\WSManLib\"
copy bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll "..\..\Bin\WSManLib\Bin\"
rem sign with strong name key after build without it
rem set ILDASM="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\ildasm.exe"
rem set ILASM="C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe"
rem %STRONG_NAME_SIGNING_TOOL% -k .\bin\\%COMPILE_MODE%\\%STRONG_NAME_KEY_FILE%
rem %ILDASM% .\bin\\%COMPILE_MODE%\Intel.Wsman.Scripting.dll /out:.\bin\\%COMPILE_MODE%\Intel.Wsman.Scripting.il
rem %ILASM% .\bin\\%COMPILE_MODE%\Intel.Wsman.Scripting.il /dll /key=.\bin\\%COMPILE_MODE%\\%STRONG_NAME_KEY_FILE% /output=.\bin\\%COMPILE_MODE%\Intel.Wsman.Scripting.dll
rem compile again with strong name (add attribute to AssemblyInfo file)
if not defined KW_SCAN (
%BuildToolsDir%Scripting\Perl.5.6.0\bin\perl.exe strongnamesigning.pl %STRONG_NAME_KEY_FILE% Properties\AssemblyInfo.cs
%STRONG_NAME_SIGNING_TOOL% -k %STRONG_NAME_KEY_FILE%
msbuild "WsmanLib.csproj" /p:configuration=%COMPILE_MODE% /t:Clean,Build > ..\..\helper.txt
if errorlevel 1 goto BuildFailed
echo WsmanLib - %COMPILE_MODE% > ..\..\log.txt
C:\Windows\System32\findstr /C:"WsmanLib -" ..\..\helper.txt >> ..\..\log.txt
)
REM Sign files
if not defined KW_SCAN (
signtool.exe sign /v /sha1 %CERT_THUMBPRINT% /fd sha256 /tr http://timestamp.comodoca.com/rfc3161 /td sha256 bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll
if errorlevel 1 goto SignFailed
signtool.exe verify /v /debug /pa bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll
if errorlevel 1 goto SignFailed
)
echo ==================================================== >> ..\..\log.txt
copy bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll "..\..\..\Intel_AMT\Bin\Ws-Management\WSManLib\StrongNamed\"
copy bin\%COMPILE_MODE%\Intel.Wsman.Scripting.dll "..\..\Bin\WSManLib\Bin\StrongNamed\"
rem copy "WsmanLib Readme" and "WsmanLib Release-notes"
copy "WsmanLib Readme.txt" ..\..\Bin\WSManLib
copy "WsmanLib Release-notes.txt" ..\..\Bin\WSManLib
if errorlevel 0 goto BuildPassed
:SignFailed
echo "Signing Failed!"
exit /B 1
:BuildFailed
echo "Build Failed!"
exit /B 1
:BuildPassed
echo "Build succeeded"
endlocal