├── .gitignore ├── README.md ├── Vagrantfile ├── db └── create.sql ├── vagrant-scripts ├── build-website.cmd ├── configure-sql-server.ps1 ├── copy-website.ps1 ├── create-database.cmd ├── creating-website-in-iis.cmd ├── install-dot-net-45.cmd ├── install-dot-net.ps1 ├── install-iis.cmd ├── install-msbuild-tools-2013.cmd ├── install-sql-server.cmd └── setup-permissions-for-website-folder.ps1 └── website ├── README.md └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | .DS_Store 3 | .vagrant -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vagrantfile for testing ASP.NET (MVC) Websites on Windows 2 | ============================= 3 | 4 | This repository contains Windows Vagrantfile ([Windows 2008 R2 x64 with Service Pack 1](https://vagrantcloud.com/ferventcoder/boxes/win2008r2-x64-nocm)) with all that you need to test ASP.NET Website. 5 | 6 | # How to use? 7 | 1. Clone repository by `git clone` 8 | 2. Put your website with compiled binary files to \website folder 9 | 3. Download ([.NET Framework](http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe)) and ([MSSQL Server](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x64_ENU.exe)) and place them into folder of cloned repository 10 | 4. Run `vagrant up` and wait while virtual machine is installed 11 | 5. Open http://127.0.0.1:1025/ in a browser 12 | 13 | ## Vagrant file includes: 14 | * IIS 7.5 15 | * .NET 4.5.2 16 | * MS SQL Server 2008 R2 17 | 18 | ## Vagrant file provides: 19 | * Test website (website directory: `C:\website`) runned on IIS (based on repository \website folder). 20 | * MSSQL Database named `test`.(Username:`test`, Password:`abcABC123!`) 21 | 22 | **Missing provisioner for component?** 23 | Not a problem! 24 | Feel free to contact me via email: vagrantfile.windows@gmail.com 25 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' 8 | 9 | if ! File.exists?('./NDP452-KB2901907-x86-x64-AllOS-ENU.exe') 10 | puts '.Net 4.5.2 installer could not be found!' 11 | puts "Please run:\n curl -O http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe" 12 | exit 1 13 | end 14 | 15 | #if ! File.exists?('./BuildTools_Full.exe') 16 | # puts 'Microsoft Build Tools 2013 installer could not be found!' 17 | # puts "Please run:\n curl -O http://download.microsoft.com/download/9/B/B/9BB1309E-1A8F-4A47-A6C5-ECF76672A3B3/BuildTools_Full.exe" 18 | # exit 1 19 | #end 20 | 21 | if ! File.exists?('./SQLEXPRWT_x64_ENU.exe') 22 | puts 'SQL Server installer could not be found!' 23 | puts "Please run:\n curl -O http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x64_ENU.exe" 24 | exit 1 25 | end 26 | 27 | 28 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 29 | 30 | config.vm.box = "ferventcoder/win2008r2-x64-nocm" 31 | config.vm.guest = :windows 32 | 33 | config.vm.communicator = "winrm" 34 | 35 | config.vm.network "private_network", ip: "192.168.123.123" 36 | config.vm.network :forwarded_port, guest: 1025, host: 1025 37 | config.vm.network :forwarded_port, guest: 3389, host: 1234 38 | config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true 39 | 40 | # .NET 4.5 41 | config.vm.provision :shell, path: "vagrant-scripts/install-dot-net.ps1" 42 | config.vm.provision :shell, path: "vagrant-scripts/install-dot-net-45.cmd" 43 | #config.vm.provision :shell, path: "vagrant-scripts/install-msbuild-tools-2013.cmd" 44 | 45 | # Database 46 | config.vm.provision :shell, path: "vagrant-scripts/install-sql-server.cmd" 47 | config.vm.provision :shell, path: "vagrant-scripts/configure-sql-server.ps1" 48 | 49 | #Restore DB 50 | config.vm.provision :shell, path: "vagrant-scripts/create-database.cmd" 51 | 52 | # IIS 53 | config.vm.provision :shell, path: "vagrant-scripts/install-iis.cmd" 54 | 55 | #Create Website 56 | config.vm.provision :shell, path: "vagrant-scripts/copy-website.ps1" 57 | #config.vm.provision :shell, path: "vagrant-scripts/build-website.cmd" 58 | config.vm.provision :shell, path: "vagrant-scripts/creating-website-in-iis.cmd" 59 | config.vm.provision :shell, path: "vagrant-scripts/setup-permissions-for-website-folder.ps1" 60 | 61 | end -------------------------------------------------------------------------------- /db/create.sql: -------------------------------------------------------------------------------- 1 | USE [master] 2 | GO 3 | 4 | /****** Object: Database [test] Script Date: 10/30/2014 3:54:00 PM ******/ 5 | CREATE DATABASE [test] 6 | GO 7 | ALTER DATABASE test MODIFY FILE 8 | ( NAME = N'test' , SIZE = 4096KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) 9 | GO 10 | ALTER DATABASE test MODIFY FILE 11 | ( NAME = N'test_log' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) 12 | GO 13 | 14 | ALTER DATABASE [test] SET COMPATIBILITY_LEVEL = 100 15 | GO 16 | 17 | IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')) 18 | begin 19 | EXEC [test].[dbo].[sp_fulltext_database] @action = 'enable' 20 | end 21 | GO 22 | 23 | ALTER DATABASE [test] SET ANSI_NULL_DEFAULT OFF 24 | GO 25 | 26 | ALTER DATABASE [test] SET ANSI_NULLS OFF 27 | GO 28 | 29 | ALTER DATABASE [test] SET ANSI_PADDING OFF 30 | GO 31 | 32 | ALTER DATABASE [test] SET ANSI_WARNINGS OFF 33 | GO 34 | 35 | ALTER DATABASE [test] SET ARITHABORT OFF 36 | GO 37 | 38 | ALTER DATABASE [test] SET AUTO_CLOSE OFF 39 | GO 40 | 41 | ALTER DATABASE [test] SET AUTO_CREATE_STATISTICS ON 42 | GO 43 | 44 | ALTER DATABASE [test] SET AUTO_SHRINK OFF 45 | GO 46 | 47 | ALTER DATABASE [test] SET AUTO_UPDATE_STATISTICS ON 48 | GO 49 | 50 | ALTER DATABASE [test] SET CURSOR_CLOSE_ON_COMMIT OFF 51 | GO 52 | 53 | ALTER DATABASE [test] SET CURSOR_DEFAULT GLOBAL 54 | GO 55 | 56 | ALTER DATABASE [test] SET CONCAT_NULL_YIELDS_NULL OFF 57 | GO 58 | 59 | ALTER DATABASE [test] SET NUMERIC_ROUNDABORT OFF 60 | GO 61 | 62 | ALTER DATABASE [test] SET QUOTED_IDENTIFIER OFF 63 | GO 64 | 65 | ALTER DATABASE [test] SET RECURSIVE_TRIGGERS OFF 66 | GO 67 | 68 | ALTER DATABASE [test] SET DISABLE_BROKER 69 | GO 70 | 71 | ALTER DATABASE [test] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 72 | GO 73 | 74 | ALTER DATABASE [test] SET DATE_CORRELATION_OPTIMIZATION OFF 75 | GO 76 | 77 | ALTER DATABASE [test] SET TRUSTWORTHY OFF 78 | GO 79 | 80 | ALTER DATABASE [test] SET ALLOW_SNAPSHOT_ISOLATION OFF 81 | GO 82 | 83 | ALTER DATABASE [test] SET PARAMETERIZATION SIMPLE 84 | GO 85 | 86 | ALTER DATABASE [test] SET READ_COMMITTED_SNAPSHOT OFF 87 | GO 88 | 89 | ALTER DATABASE [test] SET HONOR_BROKER_PRIORITY OFF 90 | GO 91 | 92 | ALTER DATABASE [test] SET RECOVERY FULL 93 | GO 94 | 95 | ALTER DATABASE [test] SET MULTI_USER 96 | GO 97 | 98 | ALTER DATABASE [test] SET PAGE_VERIFY CHECKSUM 99 | GO 100 | 101 | ALTER DATABASE [test] SET DB_CHAINING OFF 102 | GO 103 | 104 | ALTER DATABASE [test] SET READ_WRITE 105 | GO 106 | 107 | CREATE LOGIN test 108 | WITH PASSWORD = 'abcABC123!', 109 | CHECK_POLICY = ON; 110 | GO 111 | 112 | USE [test] 113 | GO 114 | 115 | -- Creates a database user for the login created above. 116 | CREATE USER test FOR LOGIN test; 117 | GO 118 | 119 | EXEC sp_addrolemember N'db_owner', N'test' -------------------------------------------------------------------------------- /vagrant-scripts/build-website.cmd: -------------------------------------------------------------------------------- 1 | echo "Building project ..." 2 | 3 | SET Directory=C:\website 4 | 5 | "%PROGRAMFILES(x86)%\MSBuild\12.0\Bin\msbuild" C:\website\web-test-app.csproj /p:outdir="%Directory%\bin";webprojectoutputdir="%Directory%";debugsymbols=false;debugtype=none;TreatWarningsAsErrors=true /t:Clean,Build /p:Configuration=Release 6 | -------------------------------------------------------------------------------- /vagrant-scripts/configure-sql-server.ps1: -------------------------------------------------------------------------------- 1 | # http://stackoverflow.com/a/9949105 2 | $ErrorActionPreference = "Stop" 3 | 4 | echo Restarting service... 5 | # Restart service so that configurations are applied 6 | restart-service -f "SQL Server (SQLEXPRESS)" 7 | echo DONE! 8 | -------------------------------------------------------------------------------- /vagrant-scripts/copy-website.ps1: -------------------------------------------------------------------------------- 1 | echo "Copy website folder" 2 | Copy-Item C:\vagrant\website C:\website -Recurse 3 | echo "Done!" 4 | -------------------------------------------------------------------------------- /vagrant-scripts/create-database.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo Creating database... 4 | "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -S .\sqlexpress -i C:\vagrant\db\create.sql 5 | echo Database is created -------------------------------------------------------------------------------- /vagrant-scripts/creating-website-in-iis.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo Creating app pool... 4 | C:\Windows\System32\inetsrv\appcmd.exe add apppool /name:website /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated 5 | 6 | echo Creating website... 7 | C:\Windows\System32\inetsrv\appcmd.exe add site /name:website /physicalPath:C:\website /bindings:http/*:1025: 8 | C:\Windows\System32\inetsrv\appcmd.exe set app "website/" /applicationPool:"website" 9 | 10 | echo Website is created. You can acces it by url http://127.0.0.1:1025/ -------------------------------------------------------------------------------- /vagrant-scripts/install-dot-net-45.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Installing .NET Framework 4.5.2 3 | C:\vagrant\NDP452-KB2901907-x86-x64-AllOS-ENU.exe /q 4 | echo Done! -------------------------------------------------------------------------------- /vagrant-scripts/install-dot-net.ps1: -------------------------------------------------------------------------------- 1 | # http://stackoverflow.com/a/9949105 2 | $ErrorActionPreference = "Stop" 3 | 4 | import-module servermanager 5 | echo "Enabling .NET Framework" 6 | add-windowsfeature as-net-framework 7 | -------------------------------------------------------------------------------- /vagrant-scripts/install-iis.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo Installing IIS 7.5, it will take a while... 4 | CMD /C START /w PKGMGR.EXE /l:log.etw /iu:IIS-WebServerRole 5 | echo Done! -------------------------------------------------------------------------------- /vagrant-scripts/install-msbuild-tools-2013.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Installing Microsoft Build Tools 2013 3 | C:\vagrant\BuildTools_Full.exe /q 4 | echo Done! -------------------------------------------------------------------------------- /vagrant-scripts/install-sql-server.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo Installing SQL Server 2008 Express R2, it will take a while... 4 | C:\vagrant\SQLEXPRWT_x64_ENU.exe /Q /Action=install /INDICATEPROGRESS /INSTANCENAME="SQLEXPRESS" /INSTANCEID="SQLExpress" /IAcceptSQLServerLicenseTerms /FEATURES=SQL,Tools /TCPENABLED=1 /SECURITYMODE="SQL" /SAPWD="#SAPassword!" 5 | 6 | echo Disabling firewall 7 | netsh advfirewall set allprofiles state off 8 | echo Done! -------------------------------------------------------------------------------- /vagrant-scripts/setup-permissions-for-website-folder.ps1: -------------------------------------------------------------------------------- 1 | # http://stackoverflow.com/a/9949105 2 | $ErrorActionPreference = "Stop" 3 | 4 | echo "Setting up access to folder" 5 | icacls "C:\website" /grant 'Everyone:(OI)(CI)F' -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | This is a root folder for your website. -------------------------------------------------------------------------------- /website/index.html: -------------------------------------------------------------------------------- 1 | < 2 | 3 | Test Page 4 | 5 | 6 |

Test page runned on IIS

7 | 8 | > --------------------------------------------------------------------------------