Updated based on code review comments

This commit is contained in:
Douglas Richardson 2016-02-08 13:05:06 -08:00
Родитель fd6258823f
Коммит 0676aa32a6
2 изменённых файлов: 73 добавлений и 14 удалений

Просмотреть файл

@ -196,19 +196,6 @@ function ValidateResourceName()
[Parameter(Mandatory=$true,Position=2)] [string] $resourceGroupName
)
# Return name for existing resource if exists
$resources = Find-AzureRmResource -ResourceGroupNameContains $resourceGroupName -ResourceType $resourceType -ResourceNameContains $resourceBaseName
if ($resources -ne $null)
{
foreach($resource in $resources)
{
if ($resource.ResourceGroupName -eq $resourceGroupName -and $resource.Name.ToLowerInvariant().StartsWith($resourceBaseName.ToLowerInvariant()))
{
return $resource.Name
}
}
}
# Generate a unique name
$resourceUrl = " "
switch ($resourceType.ToLowerInvariant())
@ -229,7 +216,7 @@ function ValidateResourceName()
"microsoft.eventhub/namespaces"
{
$resourceUrl = "servicebus.windows.net"
$resourceBaseName = $resourceBaseName.Substring(0, [System.Math]::Min(40, $resourceBaseName.Length))
$resourceBaseName = $resourceBaseName.Substring(0, [System.Math]::Min(35, $resourceBaseName.Length))
}
"microsoft.web/sites"
{
@ -237,6 +224,20 @@ function ValidateResourceName()
}
default {}
}
# Return name for existing resource if exists
$resources = Find-AzureRmResource -ResourceGroupNameContains $resourceGroupName -ResourceType $resourceType -ResourceNameContains $resourceBaseName
if ($resources -ne $null)
{
foreach($resource in $resources)
{
if ($resource.ResourceGroupName -eq $resourceGroupName -and $resource.Name.ToLowerInvariant().StartsWith($resourceBaseName.ToLowerInvariant()))
{
return $resource.Name
}
}
}
return GetUniqueResourceName $resourceBaseName $resourceUrl
}

58
build.ps1 Normal file
Просмотреть файл

@ -0,0 +1,58 @@
Param(
[Parameter(Mandatory=$True,Position=0)]
$command,
[Parameter(Mandatory=$True,Position=1)]
$configuration,
[Parameter(Mandatory=$True,Position=2)]
$environmentName,
[Parameter(Mandatory=$False,Position=3)]
$msbuild = "${Env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild.exe"
)
if (!($environmentName -match '^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{3,49}[a-zA-Z0-9]{1,1}$')) {
throw 'Invalid EnvironmentName'
}
If (!(Test-Path $msbuild)) {
Write-Warning "Use -msBuild to specify a custom msbuild path, or use the Visual Studio developer tools to run build.cmd"
throw "Couldn't find MSBuild at $msbuild"
}
# Build - see :Build in build.cmd
function Build() {
&$msbuild ("RemoteMonitoring.sln", "/v:m", "/p:Configuration=$configuration", "/t:Clean,Build")
If ($?) {
Write-Host "Building RemoteMonitoring.sln succeeded"
} Else {
throw "Building RemoteMonitoring.sln failed - See above logs"
}
}
# Package - see :Package in build.cmd
function Package() {
&$msbuild ("DeviceAdministration\Web\Web.csproj", "/v:m", "/t:Package")
If (-Not($?)) {
throw "Packaging DeviceAdministration\Web\Web.csproj failed"
}
&$msbuild ("WebJobHost\WebJobHost.csproj", "/v:m", "/t:Package")
If (-Not($?)) {
throw "Packaging WebJobHost\WebJobHost.csproj failed"
}
}
# Config - see :Config in build.cmd
function Config() {
Invoke-Expression ".\Common\Deployment\PrepareIoTSample.ps1 -environmentName $environmentName -configuration $configuration"
}
If ($command -eq 'Build' -or $command -eq 'Cloud') {
Build
Package
Config
}
ElseIf ($command -eq 'Local') {
Config
}
Else {
Write-Error "Invalid command $command"
}