Skip to content

Commit

Permalink
Initial AppVeyor configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
heaths committed May 23, 2017
1 parent 34a562b commit a0b0700
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 223 deletions.
1 change: 1 addition & 0 deletions .nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NuProj" version="0.11.14-beta" />
<package id="vswhere" version="1.0.62" />
</packages>
35 changes: 24 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,39 @@ On the command line, you can run the following commands from the solution direct

```batch
nuget install xunit.runner.console -outputdirectory packages
packages\xunit.runner.console.<version>\tools\xunit.runner.console bin\Debug\vswhere.test.dll
packages\xunit.runner.console.<version>\tools\xunit.runner.console test\VSSetup.PowerShell.Test\bin\Debug\Microsoft.VisualStudio.Setup.PowerShell.Test.dll
```

It's also recommended that, if your machine supports it, you install [Docker for Windows](https://www.docker.com/products/overview), switch to Windows containers, and test in isolated containers for runtime behavior.
If your machine supports it, you can install [Docker for Windows][docker], switch to Windows containers, and test in isolated containers for runtime behavior. You can run unit tests and integration tests together.

```batch
REM You only need to build once unless updating the Dockerfile or files it copies.
docker\build
REM This will automatically map build output. Defaults to Debug configuration. Pass -? for options.
docker\test
tools\test.cmd
```

For a faster development process, you can run `docker\run -detach`, copy the container ID printed to the window, then subsequently run `docker\test -on <container id>` replacing `<container id>` with the container ID you copied previously. You can make changes to the test data and even rebuild the project and run this command again as frequently as you need. This is especially handy for quick turn around when debugging and fixing a problem.
For a faster development process, you can run `docker-compose run test` from the _docker_ directory to start an interactive PowerShell session in a container running the Visual Studio Remote Debugger. The build output and test scripts are mounted into the container. If you rebuild or modify the tests the container is automatically updated. You can also start the container detached and run tests faster without having to restart the container.

```batch
cd docker
docker-compose up -d
To stop the container, run `docker stop <container id>`. If you did not pass `-keep` when you started the container it will be removed automatically.
REM Repeat following command as often as desired.
docker-compose exec test powershell.exe -c invoke-pester c:\tests -enableexit
docker-compose stop
```

### Debugging

You can also run `docker\run.cmd` to start an interactive shell for exploratory testing. If no other commands are passed when starting the container, the Visual Studio Remote Debugger will launch by default. Remote debugging services are discoverable on your private network.
You can run `docker-compose up -d` from the _docker_ directory to start an interactive shell for exploratory testing. If no other commands are passed when starting the container, the Visual Studio Remote Debugger will launch by default. Remote debugging services are discoverable on your private network.

1. Click *Debug -> Attach to Process*
2. Change *Transport* to "Remote (no authentication)"
3. Click *Find*
4. Click *Select* on the container (host name will be the container name)
5. Select "powershell" under *Available Processes*
6. Click *Attach*

You can configure your project to start a remote command on a machine name that matches the short container ID returned if you ran `docker\run -detach`, or that you can discover by running `docker ps` in a separate console.
If you know the host name (by default, the container name) or IP address (depending on your network configuration for the container), you can type it into the *Qualifier* directory along with port 4022, e.g. "172.22.0.1:4022".

## Pull Requests

Expand All @@ -73,3 +84,5 @@ We welcome pull requests for both bug fixes and new features that solve a common
2. All tests must pass. We have automated PR builds that will verify any PRs before they can be merged, but you are encouraged to run all tests in your development environment prior to pushing to your remote.

Thank you for your contributions!

[docker]: https://www.docker.com/products/overview
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ configuration:
- Debug
- Release

image: Visual Studio 2017

environment:
TreatWarningsAsErrors: true

Expand All @@ -23,9 +25,8 @@ cache:
before_build:
- nuget restore

test:
assemblies:
- bin\$(configuration)\*.test.dll
test_script:
- tools\test.cmd -v

artifacts:
- path: bin\$(configuration)
Expand Down
32 changes: 9 additions & 23 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.

# Require .NET Framework
FROM microsoft/windowsservercore
FROM heaths/vssetup:1.8.24
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]

# Download and install Remote Debugger
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
RUN $ErrorActionPreference = 'Stop' ; \
$ProgressPreference = 'SilentlyContinue' ; \
$VerbosePreference = 'Continue' ; \
New-Item -Path C:\Downloads -Type Directory | Out-Null ; \
Invoke-WebRequest -Uri 'https://go.microsoft.com/fwlink/?LinkId=615470&clcid=0x409' -OutFile C:\Downloads\rtools_setup_x64.exe ; \
Start-Process -Wait -FilePath C:\Downloads\rtools_setup_x64.exe -ArgumentList '-q'
Invoke-WebRequest -Uri 'https://go.microsoft.com/fwlink/?LinkId=746570&clcid=0x409' -OutFile C:\Downloads\vs_remotetools.exe ; \
Start-Process -Wait -FilePath C:\Downloads\vs_remotetools.exe -ArgumentList '-q' ; \
Remove-Item -Path C:\Downloads\vs_remotetools.exe

# Configure Remote Debugger
EXPOSE 3702 4020 4021
RUN $ErrorActionPreference = 'Stop' ; \
$VerbosePreference = 'Continue' ; \
Start-Process -Wait -FilePath 'C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe' -ArgumentList '/prepcomputer', '/private', '/quiet'

# Download and register current query APIs
ENV API_VERSION="1.8.24"
RUN $ErrorActionPreference = 'Stop' ; \
$VerbosePreference = 'Continue' ; \
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/Microsoft.VisualStudio.Setup.Configuration.Native/${env:API_VERSION}" -OutFile C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native.zip ; \
Expand-Archive -Path C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native.zip -DestinationPath C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native ; \
C:\Windows\System32\regsvr32.exe /s C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll ; \
C:\Windows\SysWOW64\regsvr32.exe /s C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Native.dll

# Install latest version of Pester for integration testing
EXPOSE 3702 4022 4023
RUN $ErrorActionPreference = 'Stop' ; \
$VerbosePreference = 'Continue' ; \
Install-PackageProvider -Name nuget -MinimumVersion 2.8.5.201 -Force ; \
Install-Module -Name Pester -Scope CurrentUser -SkipPublisherCheck -Force
Start-Process -Wait -FilePath 'C:\Program Files\Microsoft Visual Studio 15.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe' -ArgumentList '/prepcomputer', '/private', '/quiet'

# Start Remote Debugger if no other command is passed to PowerShell
ENTRYPOINT ["powershell.exe", "-ExecutionPolicy", "Unrestricted"]
CMD ["-NoExit", "-Command", "& 'C:\\Program Files\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Remote Debugger\\x64\\msvsmon.exe' /silent /noauth /anyuser"]
CMD ["-NoExit", "-Command", "& 'C:\\Program Files\\Microsoft Visual Studio 15.0\\Common7\\IDE\\Remote Debugger\\x64\\msvsmon.exe' /silent /noauth /anyuser"]
1 change: 1 addition & 0 deletions docker/Tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Rr]esults.xml
21 changes: 7 additions & 14 deletions docker/Tests/legacy.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,17 @@ Describe 'vswhere -legacy' {

Context 'no instances' {
BeforeEach {
New-Item HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 -Force | ForEach-Object {
foreach ($version in '10.0', '14.0') {
$_ | New-ItemProperty -Name $version -Value "C:\VisualStudio\$version" -Force
}
}
New-Item HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 -Force | ForEach-Object {
foreach ($version in '10.0', '14.0') {
$_ | New-ItemProperty -Name $version -Value "C:\VisualStudio\$version" -Force
}
}

Start-Process -Wait -FilePath C:\Windows\SysWOW64\regsvr32.exe -ArgumentList @(
'/s',
'/u',
'C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Native.dll'
)
Rename-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Classes\CLSID\{177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}\InprocServer32' -Name '(Default)' -NewName '_Default'
}

AfterEach {
Start-Process -Wait -FilePath C:\Windows\SysWOW64\regsvr32.exe -ArgumentList @(
'/s',
'C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Native.dll'
)
Rename-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Classes\CLSID\{177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}\InprocServer32' -Name '_Default' -NewName '(Default)'
}

It 'returns 2 instances' {
Expand Down
11 changes: 2 additions & 9 deletions docker/Tests/vswhere.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ Describe 'vswhere' {

Context '(query provider not registered)' {
BeforeAll {
Start-Process -Wait -FilePath C:\Windows\SysWOW64\regsvr32.exe -ArgumentList @(
'/s',
'/u',
'C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Native.dll'
)
Rename-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Classes\CLSID\{177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}\InprocServer32' -Name '(Default)' -NewName '_Default'
}

AfterAll {
Start-Process -Wait -FilePath C:\Windows\SysWOW64\regsvr32.exe -ArgumentList @(
'/s',
'C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Native.dll'
)
Rename-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Classes\CLSID\{177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}\InprocServer32' -Name '_Default' -NewName '(Default)'
}

It 'header contains no query version' {
Expand Down
6 changes: 6 additions & 0 deletions docker/appveyor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.

# Would prefer to only use "image" in docker-compose.yml, but AppVeyor version of docker-compose fails
# stating that a "Dockerfile" in the current directory does not exist.
FROM heaths/vssetup:1.8.24
12 changes: 12 additions & 0 deletions docker/appveyor/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.

version: "2.1"
services:
test:
# Need to override build context since AppVeyor version of docker-compose fails with just "image".
build: .
extends:
file: ../docker-compose.yml
service: test
command: -c Invoke-Pester C:\Tests -EnableExit -OutputFile C:\Tests\Results.xml -OutputFormat NUnitXml
64 changes: 0 additions & 64 deletions docker/build.cmd

This file was deleted.

19 changes: 19 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.

version: "2.1"
services:
test:
build: .
volumes:
- ../bin/${CONFIGURATION:-Debug}:C:/bin:ro
- ./Instances:C:/ProgramData/Microsoft/VisualStudio/Packages/_Instances:ro
- ./Tests:C:/Tests
- C:/VS/Community
- C:/VS/Professional
- C:/VS/Enterprise
- C:/BuildTools
network_mode: nat
expose:
- "3702/udp"
- "4022-4023"
92 changes: 0 additions & 92 deletions docker/run.cmd

This file was deleted.

9 changes: 2 additions & 7 deletions docker/test.cmd → tools/test.cmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
@echo off
@if not defined _echo echo off

REM Copyright (C) Microsoft Corporation. All rights reserved.
REM Licensed under the MIT license. See LICENSE.txt in the project root for license information.

setlocal

set script=%~nx0
set noargs=1

call %~dp0run.cmd %* -- -c Invoke-Pester C:\Tests -EnableExit
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "%~dp0\test.ps1" %*
Loading

0 comments on commit a0b0700

Please sign in to comment.