Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit e33d77c

Browse files
katmsftvinjiang
authored andcommitted
Added build script for MSbuild
1 parent d1d8b94 commit e33d77c

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

tools/prepare.bat

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
rem Set build and code folder
2+
rem Sample of the buildroot/coderoot: c:\cpp\
3+
set buildroot=%1
4+
set coderoot=%2
5+
6+
rem Set test_configurations.json's set number. This is for parallel execution. On Jenkins, v120-debug-=1, v120-release=2, v140-debug=3, v140-release=4
7+
set testconfigset=%3
8+
9+
rem Set the toolset
10+
set toolset=%4
11+
12+
rem Get the casablanca version
13+
set casaver=2.10.6
14+
15+
rem Build the packages.config file
16+
@echo
17+
set packagesfile=%buildroot%packages.config
18+
echo ^<?xml version=^"1.0^" encoding=^"utf-8^"?^> > "%packagesfile%"
19+
echo ^<packages^> >> "%packagesfile%"
20+
if "%toolset%" == "v120" echo ^<package id=^"casablanca.v120^" version=^"%casaver%^" targetFramework=^"Native^" /^> >> "%packagesfile%"
21+
if "%toolset%" == "v140" echo ^<package id=^"casablanca.v140^" version=^"%casaver%^" targetFramework=^"Native^" /^> >> "%packagesfile%"
22+
echo ^</packages^> >> "%packagesfile%"
23+
24+
rem Copy the packages.config file to code/test folder
25+
Copy "%buildroot%packages.config" "%coderoot%Microsoft.WindowsAzure.Storage\packages.config"
26+
Copy "%buildroot%packages.config" "%coderoot%Microsoft.WindowsAzure.Storage\tests\packages.config"
27+
28+
rem Copy the test_configurations.json
29+
if exist "%buildroot%test_configurations_%testconfigset%.json" copy "%buildroot%test_configurations_%testconfigset%.json" "%coderoot%Microsoft.WindowsAzure.Storage\tests\test_configurations.json"
30+
31+
rem Inject the package information to the .vcxproj file.
32+
33+
rem v120
34+
if "%toolset%" == "v120" (
35+
Echo Writing nuget package information to Microsoft.WindowsAzure.Storage.v120.vcxproj file.
36+
CALL :InjectPackageInfoProd "%coderoot%Microsoft.WindowsAzure.Storage\Microsoft.WindowsAzure.Storage.v120.vcxproj" v120 %casaver% "Microsoft.WindowsAzure.Storage.v120.vcxproj"
37+
Echo Writing nuget package information to Microsoft.WindowsAzure.Storage.UnitTests.v120.vcxproj file.
38+
CALL :InjectPackageInfoTest "%coderoot%Microsoft.WindowsAzure.Storage\tests\Microsoft.WindowsAzure.Storage.UnitTests.v120.vcxproj" v120 %casaver% "Microsoft.WindowsAzure.Storage.UnitTests.v120.vcxproj"
39+
)
40+
rem v140
41+
if "%toolset%" == "v140" (
42+
Echo Writing nuget package information to Microsoft.WindowsAzure.Storage.v140.vcxproj file.
43+
CALL :InjectPackageInfoProd "%coderoot%Microsoft.WindowsAzure.Storage\Microsoft.WindowsAzure.Storage.v140.vcxproj" v140 %casaver% "Microsoft.WindowsAzure.Storage.v140.vcxproj"
44+
Echo Writing nuget package information to Microsoft.WindowsAzure.Storage.UnitTests.v140.vcxproj file.
45+
CALL :InjectPackageInfoTest "%coderoot%Microsoft.WindowsAzure.Storage\tests\Microsoft.WindowsAzure.Storage.UnitTests.v140.vcxproj" v140 %casaver% "Microsoft.WindowsAzure.Storage.UnitTests.v140.vcxproj"
46+
)
47+
48+
rem Copy Unitest++
49+
xcopy /s %buildroot%unittest-cpp_%toolset% %coderoot%Microsoft.WindowsAzure.Storage\tests\Unittest++
50+
51+
GOTO :EOF
52+
53+
rem Function used to inject the package information
54+
:InjectPackageInfoProd
55+
@echo off
56+
setlocal EnableExtensions EnableDelayedExpansion
57+
set outputfile=%~1
58+
set inputfile=%~4.bak
59+
set inputfilefull=%~1.bak
60+
set platform=%~2
61+
set casaversion=%~3
62+
set stringtofind=" <ImportGroup Label="ExtensionTargets">"
63+
ren %outputfile% %inputfile%
64+
(
65+
echo ^<?xml version=^"1.0^" encoding=^"utf-8^"?^>
66+
for /f usebackq^ skip^=1^ delims^=^ eol^= %%a in ("%inputfilefull%") do (
67+
echo %%a
68+
if "%%~a" == %stringtofind% echo ^<Import Project=^"..\..\packages\casablanca.%platform%.%casaversion%\build\native\casablanca.%platform%.targets^" Condition=^"Exists^(^'..\..\packages\casablanca.%platform%.%casaversion%\build\native\casablanca.%platform%.targets^'^)^" ^/^>
69+
))>"%outputfile%"
70+
@echo on
71+
EXIT /B 0
72+
73+
:InjectPackageInfoTest
74+
@echo off
75+
setlocal EnableExtensions EnableDelayedExpansion
76+
set outputfile=%~1
77+
set inputfile=%~4.bak
78+
set inputfilefull=%~1.bak
79+
set platform=%~2
80+
set casaversion=%~3
81+
set stringtofind=" <ImportGroup Label="ExtensionTargets">"
82+
ren %outputfile% %inputfile%
83+
(
84+
echo ^<?xml version=^"1.0^" encoding=^"utf-8^"?^>
85+
for /f usebackq^ skip^=1^ delims^=^ eol^= %%a in ("%inputfilefull%") do (
86+
echo %%a
87+
if "%%~a" == %stringtofind% echo ^<Import Project=^"..\..\..\packages\casablanca.%platform%.%casaversion%\build\native\casablanca.%platform%.targets^" Condition=^"Exists^(^'..\..\..\packages\casablanca.%platform%.%casaversion%\build\native\casablanca.%platform%.targets^'^)^" ^/^>
88+
))>"%outputfile%"
89+
@echo on
90+
EXIT /B 0

0 commit comments

Comments
 (0)