Skip to content

Instantly share code, notes, and snippets.

@rschiefer
rschiefer / deployPackage.ps1
Last active December 28, 2016 15:04
Zero-Downtime MSDeploy Package Deployment Script
Param(
[Parameter(Mandatory = $true, Position = 0)] [string] $configName,
[Parameter(Mandatory = $true, Position = 1)] [string] $TFSUri,
[Parameter(Mandatory = $true, Position = 2)] [string] $environmentName,
[Parameter(Mandatory = $true, Position = 3)] [string] $username,
[Parameter(Mandatory = $true, Position = 4)] [string] $password,
[Parameter(Mandatory = $false, Position = 5)] [bool] $defaultStopWebsiteForDeployment = $true,
[Parameter(Mandatory = $false, Position = 6)] [int] $defaultStopWebsiteForDeploymentWaitSeconds = 22
)
D, [2017-03-22T06:04:10.979811 #16824] DEBUG -- acme-win-webdefault-nano: Berksfile found at D:/Github/TDDwithChefDSCPester/cookbooks/acme_win_web/Berksfile, loading Berkshelf
D, [2017-03-22T06:04:12.430329 #16824] DEBUG -- acme-win-webdefault-nano: Berkshelf 5.6.4 library loaded
D, [2017-03-22T06:04:12.431462 #16824] DEBUG -- acme-win-webdefault-nano: winrm requested, loading winrm gem (["~> 2.0"])
D, [2017-03-22T06:04:12.727548 #16824] DEBUG -- acme-win-webdefault-nano: winrm is loaded.
D, [2017-03-22T06:04:12.728548 #16824] DEBUG -- acme-win-webdefault-nano: winrm-fs requested, loading winrm-fs gem (["~> 1.0"])
D, [2017-03-22T06:04:12.885544 #16824] DEBUG -- acme-win-webdefault-nano: winrm-fs is loaded.
I, [2017-03-22T06:04:12.888568 #16824] INFO -- acme-win-webdefault-nano: -----> Verifying <acme-win-webdefault-nano>...
I, [2017-03-22T06:04:12.892050 #16824] INFO -- acme-win-webdefault-nano: Preparing files for transfer
D, [2017-03-22T06:04:12.893021 #16824] DEBUG -- acme-win-webdefault-nano: Creating l
---
driver:
name: hyperv
vm_switch: DefaultExternalSwitch
parent_vhd_folder: D:\VirtualMachines
parent_vhd_name: NanoDSC_2017.03.19.vhd
username: administrator
password: admin777!
memory_startup_bytes: 1073741824
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AutoDeployOnVSBuild>true</AutoDeployOnVSBuild>
<!--<AutoDeployOnVSBuild>false</AutoDeployOnVSBuild>-->
<AutoDeployPublishProfileName>LocalFile</AutoDeployPublishProfileName>
</PropertyGroup>
<Target Name="AfterBuild">
<MSBuild
Condition="'$(AutoDeployOnVSBuild)'=='true' AND '$(DeployOnBuild)'!='true'"
$acl = Get-Acl $sitePath
$permission = "$userDomain\$username","FullControl",$inherit,$propagation,"Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($permission)
$acl.AddAccessRule($accessRule)
$acl | Set-Acl $sitePath
@rschiefer
rschiefer / PrepCodeFromTFSForGithub.ps1
Last active October 17, 2022 08:21
PowerShell script for pulling code from TFVC and preparing for Github.
Function PrepareSourceForGithub {
Param(
[string]$tfsUrl,
[string]$tfsCollection = 'defaultcollection',
[string]$folderPath,
[string]$newRepoName
)
$sourceZip = "source.zip"
$sourceZipUrl = "http://$tfsUrl/$tfsCollection/_apis/tfvc/items?path=$folderPath&api-version=1.0"
Write-Host "Please provide you TFS credentials:"
public class RemoteModelValidatorAttribute : RemoteAttribute
{
public RemoteModelValidatorAttribute(Type modelType, string action, string controller) :base(action, controller)
{
AdditionalFields = string.Join(",", modelType.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).Select(p => p.Name));
}
}
[RemoteModelValidator(typeof(MyModel), "ValidateModelFields", "MyController")]
public string State { get; set; }
protected JsonResult RemoteJsonResponseForProperty(string property = null)
{
object response;
if (string.IsNullOrWhiteSpace(property))
{
property = System.Web.HttpContext.Current.Request.QueryString.Keys[0];
}
if (ModelState.ContainsKey(property) && ModelState[property].Errors.Any())
public static string GetName<T>(this Expression<Func<T>> action)
{
return GetNameFromMemberExpression(action.Body);
}
static string GetNameFromMemberExpression(Expression expression) {
if (expression is MemberExpression) {
return (expression as MemberExpression).Member.Name;
}
else if (expression is UnaryExpression) {