Skip to content

Commit

Permalink
Added .net root web.config to buildpack
Browse files Browse the repository at this point in the history
Change-Id: I32d6db8b4810e27bc699b800c70b8b7488da524f
  • Loading branch information
florindragos committed Oct 4, 2013
1 parent 46321b7 commit bf6d65f
Show file tree
Hide file tree
Showing 12 changed files with 1,606 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/Buildpacks/iis/iishwc/applicationHostTemplate.config
Expand Up @@ -144,13 +144,13 @@
<add name="http" />
</listenerAdapters>
<log>
<centralBinaryLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<centralW3CLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<centralBinaryLogFile enabled="true" directory="%HOME%\logs" />
<centralW3CLogFile enabled="true" directory="%HOME%\logs" />
</log>
<sites>
<siteDefaults>
<logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
<logFile logFormat="W3C" directory="%HOME%\logs" />
<traceFailedRequestsLogging directory="%HOME%\logs" />
</siteDefaults>
<applicationDefaults />
<virtualDirectoryDefaults allowSubDirConfig="true" />
Expand All @@ -159,7 +159,7 @@
</system.applicationHost>
<system.webServer>
<asp>
<cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
<cache diskTemplateCacheDirectory="%HOME%\tmp\ASP Compiled Templates" />
</asp>
<caching enabled="true" enableKernelCache="true">
</caching>
Expand Down Expand Up @@ -213,7 +213,7 @@
<add name="ApplicationInitializationModule" image="%windir%\System32\inetsrv\warmup.dll" />
<add name="WebSocketModule" image="%windir%\System32\inetsrv\iiswsock.dll" />
</globalModules>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<httpCompression directory="%HOME%\tmp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
Expand Down
49 changes: 49 additions & 0 deletions src/Buildpacks/iis/iishwc/detectVersion.ps1
@@ -0,0 +1,49 @@
$script:scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$script:appPath = (get-item $script:scriptPath).parent.FullName

$applicationHostPath = Join-Path $script:scriptPath 'applicationHost.config'
$webConfig = New-Object System.Xml.XmlDocument
$webConfig.Load($applicationHostPath)
$val = $webConfig.SelectSingleNode("/configuration/system.applicationHost/applicationPools/add").Attributes["enable32BitAppOnWin64"].Value.ToString()
$enabled32bit = [System.Convert]::ToBoolean($val)

if ($enabled32bit)
{
$bitness = "86"
}
else
{
$bitness = "64"
}

$webConfigPath = Join-Path $script:appPath 'web.config'
$webConfig = New-Object System.Xml.XmlDocument
$webConfig.Load($webConfigPath)

$node = $webConfig.SelectSingleNode("/configuration/system.web/compilation/@targetFramework")
if ($node)
{
Write-Host("Application requires asp.net v4.0");
$version = 40
}
else
{
Write-Host("Application requires asp.net v2.0");
$version = 20
}

$rootWebConfigFileName = "rootWeb" + $version + $bitness + ".config"
$rootWebConfigPath = Join-Path $script:scriptPath $rootWebConfigFileName

$rootWebConfig = New-Object System.Xml.XmlDocument
$rootWebConfig.Load($rootWebConfigPath)
$tmpPath = Join-Path $env:HOME "tmp"
$compilationPath = Join-Path $tmpPath "aspnet_compilation"

$element = $rootWebConfig.SelectSingleNode("configuration/system.web/compilation")
$element.SetAttribute('tempDirectory', $compilationPath)

$rootWebConfig.Save($rootWebConfigPath)

$host.SetShouldExit($version)
exit
Binary file modified src/Buildpacks/iis/iishwc/iishwcx64.exe
Binary file not shown.
Binary file modified src/Buildpacks/iis/iishwc/iishwcx86.exe
Binary file not shown.
329 changes: 329 additions & 0 deletions src/Buildpacks/iis/iishwc/rootWeb2064.config

Large diffs are not rendered by default.

329 changes: 329 additions & 0 deletions src/Buildpacks/iis/iishwc/rootWeb2086.config

Large diffs are not rendered by default.

377 changes: 377 additions & 0 deletions src/Buildpacks/iis/iishwc/rootWeb4064.config

Large diffs are not rendered by default.

475 changes: 475 additions & 0 deletions src/Buildpacks/iis/iishwc/rootWeb4086.config

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions src/Buildpacks/iis/iishwc/src/iishwc/iishwc.cpp
Expand Up @@ -20,6 +20,8 @@ HRESULT _cdecl wmain(int argc, wchar_t * argv[])
WCHAR wszInetPath[MAX_PATH];
WCHAR wszDllPath[MAX_PATH];
WCHAR wszCfgPath[MAX_PATH];
WCHAR wszRootWebCfgPath[MAX_PATH];
WCHAR wszInstanceName[30];

// Retrieve the path of the Inetsrv folder.
DWORD nSize = ::ExpandEnvironmentStringsW(L"%windir%\\system32\\inetsrv",wszInetPath,MAX_PATH);
Expand All @@ -41,17 +43,21 @@ HRESULT _cdecl wmain(int argc, wchar_t * argv[])
wcscat_s(wszDllPath,MAX_PATH-1,L"\\");
wcscat_s(wszDllPath,MAX_PATH-1,WEB_CORE_DLL_NAME);

if (argc > 1)
if (argc == 4)
{
// Use the first argument from the run command as the config file path
wcscpy_s(wszCfgPath,MAX_PATH-1,argv[1]);

// Use the second argument from the run command as the root web config file path
wcscpy_s(wszRootWebCfgPath,MAX_PATH-1,argv[2]);

// Use the third argument as the name of the web core instance
wcscpy_s(wszInstanceName,29,argv[3]);
}
else
{
// Set the applicationHost.config to default in the current dir.
::GetCurrentDirectory(MAX_PATH-1,wszCfgPath);
wcscat_s(wszCfgPath,MAX_PATH-1,L"\\");
wcscat_s(wszCfgPath,MAX_PATH-1,L"applicationHost.config");
printf("Invalid parameters, use the following: iishwc [applicationHost.config] [rootweb.config] [instance-id]");
return 1;
}

// Create a pointer to WebCoreActivate.
Expand Down Expand Up @@ -111,7 +117,7 @@ HRESULT _cdecl wmain(int argc, wchar_t * argv[])
// Return an activation status to the console.
printf("Activating the Web core...\n");
// Activate the Web core.
hr = pfnWebCoreActivate(wszCfgPath,L"",L"TestWebCore");
hr = pfnWebCoreActivate(wszCfgPath, wszRootWebCfgPath, wszInstanceName);
// Test for an error.
if (FAILED(hr))
{
Expand Down
12 changes: 10 additions & 2 deletions src/Buildpacks/iis/iishwc/src/iishwc/iishwc.vcxproj
Expand Up @@ -68,15 +68,23 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>iishwcx86</TargetName>
<OutDir>$(SolutionDir)\..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>iishwcx64</TargetName>
<OutDir>$(SolutionDir)\..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>iishwcx86</TargetName>
<OutDir>$(SolutionDir)\..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>iishwcx64</TargetName>
<OutDir>$(SolutionDir)\..\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down Expand Up @@ -122,7 +130,7 @@
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
Expand All @@ -141,7 +149,7 @@
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
Expand Down
17 changes: 16 additions & 1 deletion src/Buildpacks/iis/iishwc/start.bat
@@ -1,3 +1,18 @@
@echo off
powershell -ExecutionPolicy bypass "& %~dp0\start.ps1"
IF %ERRORLEVEL% EQU 0 (%~dp0\iishwcx64.exe %~dp0applicationHost.config) ELSE (%~dp0\iishwcx86.exe %~dp0applicationHost.config)
set bitness=%ERRORLEVEL%
powershell -ExecutionPolicy bypass "& %~dp0\detectVersion.ps1"
set version=%ERRORLEVEL%
IF %bitness% EQU 0 (
IF %version% EQU 40 (
%~dp0\iishwcx64.exe %~dp0applicationHost.config %~dp0rootWeb4064.config %PORT%
) ELSE (
%~dp0\iishwcx64.exe %~dp0applicationHost.config %~dp0rootWeb2064.config %PORT%
)
) ELSE (
IF %version% EQU 40 (
%~dp0\iishwcx86.exe %~dp0applicationHost.config %~dp0rootWeb4086.config %PORT%
) ELSE (
%~dp0\iishwcx86.exe %~dp0applicationHost.config %~dp0rootWeb2086.config %PORT%
)
)
4 changes: 3 additions & 1 deletion src/Buildpacks/iis/iishwc/start.ps1
Expand Up @@ -144,4 +144,6 @@ foreach ($file in $configFiles)
}

Write-Output("Starting IIS Process")
exit $script:exitCode

$host.SetShouldExit($script:exitCode)
exit

0 comments on commit bf6d65f

Please sign in to comment.