繁体   English   中英

创建Windows虚拟机以创建.NET和IIS流浪者环境

[英]Creating Windows virtual machine to create .NET and IIS vagrant environment

作为使用OS X的前端开发人员,与基于Windows的开发人员一起工作,我想创建一个包含Windows,IIS,.NET,SQL Server和Sitecore的开发环境。

目标是绕过创建静态HTML,CSS和JS文件,而直接进入.NET和Sitecore中的视图和模型文件。 使用Vagrant,我可以访问localhost开发环境,使我可以登录Sitecore并在开发时查看前端。

我知道旧的modern.ie网站(现在是Microsoft Edge VM)可以提供良好的入门环境。 我想使用Vagrant将各种软件(例如IIS,.NET,SQL Server和Sitecore)设置到VM中。

如果不是modern.ie VM,我相信可以使用任何获得许可的Windows 10 Professional ISO来完成。 我的目标是使用Vagrant尽可能地自动执行此设置,以便在我运行vagrant up ,可以为前端开发准备好开发环境。

我需要经过什么流程才能工作?

您应该看一下shell Provisioning Provisioning 这些脚本在vagrant up期间运行vagrant up因此在进入Windows之前

在您的Vagrantfile中,您将添加

  ......
  config.vm.define "win_10" do |win10|
    win10.vm.box = "windows_10"

    win10.vm.provision "shell", path: "puppet/install_ariba/test/install_win_jdk.ps1"
    win10.vm.provision "shell", path: "puppet/install_ariba/test/install_browsers.ps1"
  ......

install_browsers.ps1看起来像

function LogWrite {
    Param ([string]$logstring)
    $now = Get-Date -format s
    Add-Content $Logfile -value "$now $logstring"
    Write-Host $logstring
}

function CheckLocation {
    Param ([string]$location)
    if (!(Test-Path  $location)) {
        throw [System.IO.FileNotFoundException] "Could not download to Destination $location."
    }
}

function add-host([string]$ip, [string]$hostname) {
    $hostsPath = "$env:windir\System32\drivers\etc\hosts"
    $ip + "`t`t" + $hostname | Out-File -encoding ASCII -append $hostsPath
}

$Logfile = "C:\Windows\Temp\chrome-firefox-install.log"

$FF_VER="45.0.1";
$firefox_source = "https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FF_VER/win32/en-US/Firefox%20Setup%20$FF_VER.exe"
$firefox_destination = "C:\Windows\Temp\firefoxinstaller.exe"

LogWrite "Starting to download files $firefox_source"
try {
    LogWrite 'Downloading Firefox...'
    (New-Object System.Net.WebClient).DownloadFile($firefox_source, $firefox_destination)
    CheckLocation $firefox_destination
} catch [Exception] {
    LogWrite "Exception during download. Probable cause could be that the directory or the file didn't exist."
    LogWrite '$_.Exception is' $_.Exception
}

LogWrite 'Starting firefox install process.'
try {
    Start-Process -FilePath $firefox_destination -ArgumentList "-ms" -Wait -PassThru
} catch [Exception] {
    LogWrite 'Exception during install process.'
    LogWrite '$_.Exception is' $_.Exception
}

LogWrite 'Update hostfile'
add-host "192.168.90.52" "pws.app"

LogWrite 'All done. Goodbye.'

在此示例中,我下载并安装了特定版本的FireFox并更新了主机文件。 网上有很多使用Powershell脚本安装软件的示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM