Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Import VSTestHost code.
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Apr 24, 2015
1 parent 034c2eb commit 1edffcd
Show file tree
Hide file tree
Showing 31 changed files with 2,820 additions and 0 deletions.
91 changes: 91 additions & 0 deletions BuildVSTestHost.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
param([string] $options, [switch] $sign, [switch] $mocksign, [switch] $rebuild)

if ($rebuild) {
$buildtarget = "Rebuild"
} else {
$buildtarget = "Build"
}

if (-not (get-command msbuild -EA 0)) {
Write-Error "Visual Studio build tools are required."
exit 1
}

$projectDir = Split-Path -parent $MyInvocation.MyCommand.Definition

$buildroot = $projectDir
while ((Test-Path $buildroot) -and -not (Test-Path "$buildroot\build.root")) {
$buildroot = (Split-Path -Parent $buildroot)
}
Write-Output "Build Root: $buildroot"

if (-not $outdir) {
$outdir = "$projectDir"
}
Write-Output "Writing output MSIs to $outdir"

$originalbuildtarget = $buildtarget
if ($sign -or $mocksign) {
$buildtarget = "BuildVSTestHost"
}

msbuild $projectDir\Installer\Installer.wixproj `
/fl /flp:logfile="$projectDir\VSTestHost.build.log" `
/v:m `
/nologo `
/t:$buildtarget `
/p:VSTestHostTarget=$originalbuildtarget `
/p:Configuration=Release `
$options

if (-not $?) {
Throw "Build failed"
}

if ($sign -or $mocksign) {
Write-Output "Submitting signing job"
if ($sign) {
Import-Module -force $buildroot\Build\BuildReleaseHelpers.psm1
} else {
Import-Module -force $buildroot\Build\BuildReleaseMockHelpers.psm1
}

$approvers = "smortaz", "dinov", "stevdo", "pminaev", "gilbertw", "huvalo", "sitani", "jinglou", "crwilcox"
$approvers = @($approvers | Where-Object {$_ -ne $env:USERNAME})

$dllfiles = @(Get-ChildItem "$projectDir\VSTestHost\bin\Release_*\Microsoft.VisualStudioTools.VSTestHost.*.dll" | %{ @{path=$_.FullName; name=$_.Name} })
$destdir = "$outdir\VSTestHost\bin\SignedBinaries"
$dlljob = begin_sign_files $dllfiles $destdir $approvers "VS Test Host" "http://pytools.codeplex.com" `
"VS Test Host" "Visual Studio; test" "authenticode;strongname"

end_sign_files $dlljob

Write-Output "Rebuilding MSI with signed binaries"

msbuild $projectDir\Installer\Installer.wixproj `
/fl /flp:logfile="$projectDir\VSTestHost.build_signed.log" `
/v:m `
/nologo `
/t:$originalbuildtarget `
/p:VSTestHostSignedBinariesPath=$destdir `
/p:Configuration=Release

if (-not $?) {
Throw "Rebuild failed"
}

Write-Output "Submitting MSI signing job"
$msifiles = @(@{path="$projectDir\Installer\bin\Release\VSTestHost.msi"; name="VSTestHost.msi"})
$msijob = begin_sign_files $msifiles $outdir $approvers "VS Test Host Installer" "http://pytools.codeplex.com" `
"VS Test Host" "Visual Studio; test" "authenticode"

end_sign_files $msijob
} else {
Copy-Item "$projectDir\Installer\bin\Release\VSTestHost.msi" $outdir
}

Write-Output ""
Write-Output " *"
Write-Output " * Final MSI is at $(gci $outdir\*.msi)"
Write-Output " *"
Write-Output ""
Binary file added DisableSkipVerification.reg
Binary file not shown.
Binary file added DisableVSTestHost12.0.reg
Binary file not shown.
Binary file added DisableVSTestHost14.0.reg
Binary file not shown.
Binary file added EnableSkipVerification.reg
Binary file not shown.
Binary file added EnableVSTestHost12.0.reg
Binary file not shown.
Binary file added EnableVSTestHost14.0.reg
Binary file not shown.
86 changes: 86 additions & 0 deletions Installer/Installer.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.8</ProductVersion>
<ProjectGuid>19b3ef60-2d4b-4598-9f31-bcd75751b244</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>VSTestHost</OutputName>
<OutputType>Package</OutputType>
<DefineSolutionProperties>false</DefineSolutionProperties>
<WixInstallPath>$(MSBuildThisFileDirectory)\..\..\Wix\3.7</WixInstallPath>
<WixTargetsPath>$(WixInstallPath)\Wix.targets</WixTargetsPath>
<VSTestHostTarget Condition="'$(VSTestHostTarget)' == ''">Build</VSTestHostTarget>
<VSTargetVersions Condition="'$(VSTargetVersions)' == ''">10;11;12;14</VSTargetVersions>
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<Import Project="$(WixTargetsPath)" />

<Target Name="_GetVSTestHostItems">
<ItemGroup>
<_VSVersions Include="$(VSTargetVersions)" />
</ItemGroup>
<!-- No signed binaries provided, so rebuild VSTestHost from source. -->
<ItemGroup Condition="'$(VSTestHostSignedBinariesPath)' == ''">
<_VSTestHost Include="@(_VSVersions->'..\VSTestHost\bin\$(Configuration)_%(Identity).0\Microsoft.VisualStudioTools.VSTestHost.%(Identity).0.dll')">
<PkgDefFullPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\VSTestHost\bin\$(Configuration)_%(Identity).0\Microsoft.VisualStudioTools.VSTestHost.%(Identity).0.pkgdef'))</PkgDefFullPath>
<Project>$(MSBuildThisFileDirectory)\..\VSTestHost\VSTestHost.csproj</Project>
<Properties>Platform=AnyCPU;Configuration=$(Configuration);VisualStudioVersion=%(Identity).0;DeployExtension=false</Properties>
<VSVersion>%(Identity)</VSVersion>
</_VSTestHost>
</ItemGroup>

<!-- We have signed binaries, so use those instead of rebuilding. -->
<ItemGroup Condition="'$(VSTestHostSignedBinariesPath)' != ''">
<_VSTestHost Include="@(_VSVersions->'$(VSTestHostSignedBinariesPath)\Microsoft.VisualStudioTools.VSTestHost.%(Identity).0.dll')">
<PkgDefFullPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\VSTestHost\bin\$(Configuration)_%(Identity).0\Microsoft.VisualStudioTools.VSTestHost.%(Identity).0.pkgdef'))</PkgDefFullPath>
<VSVersion>%(Identity)</VSVersion>
</_VSTestHost>
</ItemGroup>
</Target>

<Target Name="BuildVSTestHost" DependsOnTargets="_GetVSTestHostItems" Condition="'$(VSTestHostSignedBinariesPath)' == ''">
<MSBuild Projects="@(_VSTestHost->'%(Project)')"
BuildInParallel="true"
Targets="$(VSTestHostTarget)"
Properties="%(Properties)"
StopOnFirstFailure="false"
ContinueOnError="true"
UnloadProjectsOnCompletion="true" />
</Target>

<Target Name="GetVSTestHostItems" DependsOnTargets="_GetVSTestHostItems;BuildVSTestHost">
<ItemGroup>
<VSTestHost Include="@(_VSTestHost)" Condition="Exists('%(FullPath)')" />
</ItemGroup>
</Target>

<Target Name="SetConstants" DependsOnTargets="GetVSTestHostItems" BeforeTargets="BeforeBuild">
<Error Text="No versions of VSTestHost are available." Condition="'@(VSTestHost)' == ''" />
<PropertyGroup>
<DefineConstants>
SupportedVSVersions=@(VSTestHost->'%(VSVersion)','%3b');
@(VSTestHost->'VSTestHostDLLSource%(VSVersion)=%(FullPath)',';');
@(VSTestHost->'VSTestHostPkgdefSource%(VSVersion)=%(PkgdefFullPath)',';');
@(VSTestHost->'VSTestHostName%(VSVersion)=Microsoft.VisualStudioTools.VSTestHost.%(VSVersion).0',';');
$(DefineConstants)
</DefineConstants>
</PropertyGroup>
</Target>
</Project>
10 changes: 10 additions & 0 deletions Installer/Installer.wixproj.vspscc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}
205 changes: 205 additions & 0 deletions Installer/Product.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="VS Test Host Adapter"
Language="1033"
Version="1.0.1.0"
Manufacturer="Microsoft Corporation"
UpgradeCode="4ff73677-1aed-4738-8ac7-ffc843e1cbd0">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x86" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" CompressionLevel="high" />

<?ifdef VSTestHostDLLSource10 ?>
<Feature Id="VSTestHost_10" Title="Visual Studio 2010 Support">
<Condition Level="0">NOT VS10TARGET</Condition>
<Component Id="VSTestHost_10" Directory="GAC" Guid="{EE43BF7D-1971-4ECC-9749-F55DFDC442A3}">
<File Name="$(var.VSTestHostName10).dll" Source="$(var.VSTestHostDLLSource10)" KeyPath="yes" Assembly=".net" />
</Component>
<Component Id="Pkgdef_10" Directory="VS10Target" Guid="{E7460D09-AE6F-4990-9AD7-1BEE658A7A03}">
<File Name="$(var.VSTestHostName10).pkgdef" Source="$(var.VSTestHostPkgdefSource10)" KeyPath="yes" />
</Component>
</Feature>
<?endif?>

<?ifdef VSTestHostDLLSource11 ?>
<Feature Id="VSTestHost_11" Title="Visual Studio 2012 Support">
<Condition Level="0">NOT VS11TARGET</Condition>
<Component Id="VSTestHost_11" Directory="GAC" Guid="{30E9AAC8-47FF-4232-B8BB-37A4B31AA230}">
<File Name="$(var.VSTestHostName11).dll" Source="$(var.VSTestHostDLLSource11)" KeyPath="yes" Assembly=".net" />
</Component>
<Component Id="Pkgdef_11" Directory="VS11Target" Guid="{C8920EC5-07B2-4035-AF66-13675AB5C2AC}">
<File Name="$(var.VSTestHostName11).pkgdef" Source="$(var.VSTestHostPkgdefSource11)" KeyPath="yes" />
</Component>
</Feature>
<?endif?>

<?ifdef VSTestHostDLLSource12 ?>
<Feature Id="VSTestHost_12" Title="Visual Studio 2013 Support">
<Condition Level="0">NOT VS12TARGET</Condition>
<Component Id="VSTestHost_12" Directory="GAC" Guid="{E8FF9E25-2638-4F77-A3C6-6239F4A15947}">
<File Name="$(var.VSTestHostName12).dll" Source="$(var.VSTestHostDLLSource12)" KeyPath="yes" Assembly=".net" />
</Component>
<Component Id="Pkgdef_12" Directory="VS12Target" Guid="{84D74953-D79C-48B3-A11F-67A3259A1147}">
<File Name="$(var.VSTestHostName12).pkgdef" Source="$(var.VSTestHostPkgdefSource12)" KeyPath="yes" />
</Component>

<ComponentRef Id="Host_VisualStudio_12" />
</Feature>
<?endif?>

<?ifdef VSTestHostDLLSource14 ?>
<Feature Id="VSTestHost_14" Title="Visual Studio 2015 Support">
<Condition Level="0">NOT VS14TARGET</Condition>
<Component Id="VSTestHost_14" Directory="GAC" Guid="{63CFA056-438D-4839-915D-3F7B4EC07C83}">
<File Name="$(var.VSTestHostName14).dll" Source="$(var.VSTestHostDLLSource14)" KeyPath="yes" Assembly=".net" />
</Component>
<Component Id="Pkgdef_14" Directory="VS14Target" Guid="{C3FC89B5-962D-450F-B1BD-6646DC3D1A3E}">
<File Name="$(var.VSTestHostName14).pkgdef" Source="$(var.VSTestHostPkgdefSource14)" KeyPath="yes" />
</Component>

<ComponentRef Id="Host_VisualStudio_14" />
</Feature>
<?endif?>

<InstallExecuteSequence>
<InstallExecute After="PublishProduct" />
</InstallExecuteSequence>

<!-- Execute devenv /setup -->
<?foreach VSSKU in VS;WD;VWD?>
<?foreach VSVersion in $(var.SupportedVSVersions)?>

<PropertyRef Id="$(var.VSSKU)$(var.VSVersion)INSTALLED" />

<CustomAction Id="$(var.VSSKU)$(var.VSVersion)Setup" Property="$(var.VSSKU)$(var.VSVersion)INSTALLED" ExeCommand="/setup" Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="$(var.VSSKU)$(var.VSVersion)Setup_Rollback" Property="$(var.VSSKU)$(var.VSVersion)INSTALLED" ExeCommand="/setup" Execute="rollback" Return="check" Impersonate="no" />

<InstallExecuteSequence>
<Custom Action="$(var.VSSKU)$(var.VSVersion)Setup_Rollback" Before="$(var.VSSKU)$(var.VSVersion)Setup">
$(var.VSSKU)$(var.VSVersion)INSTALLED
</Custom>
<Custom Action="$(var.VSSKU)$(var.VSVersion)Setup" Before="InstallFinalize">
$(var.VSSKU)$(var.VSVersion)INSTALLED
</Custom>
</InstallExecuteSequence>

<UI>
<ProgressText Action="$(var.VSSKU)$(var.VSVersion)Setup" Template="Running /setup for $(var.VSSKU) $(var.VSVersion).0" />
<ProgressText Action="$(var.VSSKU)$(var.VSVersion)Setup_Rollback" Template="Rolling back /setup for $(var.VSSKU) $(var.VSVersion).0" />
</UI>

<?endforeach?>
<?endforeach?>
</Product>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir" />
</Fragment>

<Fragment>
<DirectoryRef Id="TARGETDIR">
<Directory Id="GAC" />
</DirectoryRef>
</Fragment>

<!--
We iterate over every combination of SKU and version to generate the
components, but only the ones referenced above will be included in the MSI.
-->
<?foreach VSSKU in VisualStudio;WDExpress;VWDExpress?>
<?foreach VSVersion in $(var.SupportedVSVersions)?>

<?ifdef Condition?>
<?undef Condition?>
<?endif?>
<?if "$(var.VSSKU)" = "VisualStudio"?>
<?define Condition=VS$(var.VSVersion)INSTALLED?>
<?elseif "$(var.VSSKU)" = "WDExpress"?>
<?define Condition=WD$(var.VSVersion)INSTALLED?>
<?elseif "$(var.VSSKU)" = "VWDExpress"?>
<?define Condition=VWD$(var.VSVersion)INSTALLED?>
<?else?>
<?define Condition=$(var.VSSKU)_$(var.VSVersion)?>
<?endif?>

<?define VSHiveKey=SOFTWARE\Microsoft\$(var.VSSKU)\$(var.VSVersion).0?>
<?define AssemblyName=Microsoft.VisualStudioTools.VSTestHost.$(var.VSVersion).0, Version=$(var.VSVersion).0.1.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A?>

<!--
This component is the registration to launch unit tests
-->
<Fragment>
<PropertyRef Id="$(var.Condition)"/>

<Component Id="Host_$(var.VSSKU)_$(var.VSVersion)" Directory="TARGETDIR" Guid="*">
<Condition>$(var.Condition)</Condition>

<RegistryKey Root="HKLM" Key="$(var.VSHiveKey)">
<RegistryKey Key="EnterpriseTools\QualityTools\HostAdapters\VSTestHost">
<RegistryValue Name="Type" Value="Microsoft.VisualStudioTools.VSTestHost.TesterTestAdapter, $(var.AssemblyName)" Type="string" KeyPath="yes" />
<RegistryValue Name="EditorType" Value="Microsoft.VisualStudioTools.VSTestHost.TesterTestControl, $(var.AssemblyName)" Type="string" />
<RegistryValue Key="SupportedTestTypes" Name="{13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}" Value="Unit Test" Type="string" />
</RegistryKey>
<RegistryKey Key="EnterpriseTools\QualityTools\TestTypes\{13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}\SupportedHostAdapters">
<RegistryValue Name="VSTestHost" Value="[ProductName]" Type="string" />
</RegistryKey>
</RegistryKey>
</Component>
</Fragment>

<?undef AssemblyName?>
<?undef VSHiveKey?>
<?endforeach?>
<?endforeach?>


<!--
Create a search for every version combination. Only the referenced properties
will be included in the MSI.
-->
<?foreach VSVersion in $(var.SupportedVSVersions)?>
<Fragment>
<Property Id="VS$(var.VSVersion)TARGET" Secure="yes">
<RegistrySearch Id="VSInstallDir_$(var.VSVersion)" Root="HKLM" Key="Software\Microsoft\VisualStudio\$(var.VSVersion).0\Setup\VS" Name="ProductDir" Type="directory" />
</Property>
<DirectoryRef Id="TARGETDIR">
<Directory Id="VS$(var.VSVersion)TARGET">
<Directory Id="VS$(var.VSVersion)Common7" Name="Common7">
<Directory Id="VS$(var.VSVersion)IDE" Name="IDE">
<Directory Id="VS$(var.VSVersion)CommonExtensions" Name="CommonExtensions">
<!-- Shouldn't really be installing here, but it's the easiest
way to be loaded in Express SKUs without having to install
multiple files. -->
<Directory Id="VS$(var.VSVersion)Target" Name="Platform" />
</Directory>
</Directory>
</Directory>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<Property Id="VS$(var.VSVersion)INSTALLED" Secure="yes">
<RegistrySearch Id="VSInstalled_$(var.VSVersion)" Root="HKLM" Key="Software\Microsoft\VisualStudio\$(var.VSVersion).0" Name="InstallDir" Type="directory">
<FileSearch Id="devenv_$(var.VSVersion)" Name="devenv.exe"/>
</RegistrySearch>
</Property>
</Fragment>
<Fragment>
<Property Id="WD$(var.VSVersion)INSTALLED" Secure="yes">
<RegistrySearch Id="WDInstalled_$(var.VSVersion)" Root="HKLM" Key="Software\Microsoft\WDExpress\$(var.VSVersion).0" Name="InstallDir" Type="directory">
<FileSearch Id="wdexpress_$(var.VSVersion)" Name="wdexpress.exe"/>
</RegistrySearch>
</Property>
</Fragment>
<Fragment>
<Property Id="VWD$(var.VSVersion)INSTALLED" Secure="yes">
<RegistrySearch Id="WDInstalled_$(var.VSVersion)" Root="HKLM" Key="Software\Microsoft\VWDExpress\$(var.VSVersion).0" Name="InstallDir" Type="directory">
<FileSearch Id="vwdexpress_$(var.VSVersion)" Name="vwdexpress.exe"/>
</RegistrySearch>
</Property>
</Fragment>

<?endforeach ?>
</Wix>
Loading

0 comments on commit 1edffcd

Please sign in to comment.