Skip to content

Instantly share code, notes, and snippets.

@edwinf
edwinf / GetBuildNumberFromDatabase.cs
Created May 21, 2012 01:02
TFS 2010 custom workflow activity to get a version number from a database
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Build.Client;
using System.Activities;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using Microsoft.TeamFoundation.Build.Workflow.Tracking;
@edwinf
edwinf / ChangesetTable.ps1
Created May 27, 2012 01:54
Powershell script to report TFS checkin history
Get-TfsItemHistory "$/PROJECTNAME" -Recurse -Version "D1/1/10~D12/31/10" | Sort CreationDate | Select ChangeSetId,Committer,Comment,CreationDate | Format-Table ChangeSetId,CreationDate,Committer,Comment -Auto -Wrap | out-file "full.txt"
@edwinf
edwinf / model.tt
Created May 29, 2012 01:10
How to modify the EF complex object template to not update unless the value is different
<#=code.SpaceAfter(Accessibility.ForSetter(complexProperty))#>set
{
if ( (<#=code.FieldName(complexProperty)#> != null && value == null) ||
(<#=code.FieldName(complexProperty)#> == null && value != null) ||
(<#=code.FieldName(complexProperty)#> != null && !<#=code.FieldName(complexProperty)#>.Equals(value))
)
{
<#=ChangingMethodName(complexProperty)#>(value);
ReportPropertyChanging("<#=complexProperty.Name#>");
<#=code.FieldName(complexProperty)#> = SetValidValue(<#=code.FieldName(complexProperty)#>, value, "<#=complexProperty.Name#>");
@edwinf
edwinf / gist:2868815
Created June 4, 2012 14:42
Console app to generate a xunit project file from a file search
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
namespace BuildXUnitProjectFile
{
class Program
@edwinf
edwinf / updateGuid.ps1
Created July 6, 2012 16:44
update guid attribute on an assemblyinfo.cs file
if ($args.Length -eq 1)
{
if (Test-Path $args[0])
{
$tempFile = $args[0]+".tmp";
Write-Host "Getting content from: "$args[0];
Write-Host "Writing to temp file: " $tempFile;
$newGuid = [System.Guid]::NewGuid().Guid;
$newGuid = "Guid(""" + $newGuid + """)";
Write-Host "Replacing with: " $newGuid;
@edwinf
edwinf / ServiceContainer-Partial.cs
Created August 1, 2012 01:59
WCF Proxy through DI
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WCFDIProxy
{
public partial class ServiceContainer
{
partial void GetServiceLocators(ref List<ServiceContainer.ServiceLocator> locators)
@edwinf
edwinf / gist:3253574
Created August 4, 2012 02:25
TFS - Find Old Shelvesets
$tfsServerString = "Path To Collection"
$tfs = Get-TfsServer $tfsServerString
Get-TfsShelveset -Server $tfs -owner * | where {$_.CreationDate -le [DateTime]::Now.AddDays(-90)} | Sort {$_.CreationDate} | Format-Table
@edwinf
edwinf / gist:3700093
Created September 11, 2012 17:33
Add Project Collection Administrators to a TFS project that is missing the permission definition
1) Grab the Guid of the project in question. I did through through VS 2010 and clicking the properties of the project itself.
2) Grab the SSID of the project Collection Administrators. (You might be able to skip this step, I just couldn't get the syntax right in TFSSecurity to use it by name).
tfssecurity /i "Project Collection Administrators" /collection:<collectionPath>
output:
SID: S-1-**********
@edwinf
edwinf / RubyFileExt.java
Last active December 21, 2015 15:49
Java extension to the jruby runtime to open a file with the new Java.nio classes that open a file with read | write | delete share permissions.
/**
* Created with IntelliJ IDEA.
* User: efrey
* Date: 6/11/13
* Time: 11:00 AM
* To change this template use File | Settings | File Templates.
*
* http://bugs.sun.com/view_bug.do?bug_id=6357433
*
*
@edwinf
edwinf / UpdateNonSettingParameters
Created January 22, 2015 15:58
Pre-Deployment script to change additional settings in the cscfg file for Octopus Cloud Service deployments.
$subnetName = $OctopusParameters["Azure Subnet Name"]
$virtualNetworkName = $OctopusParameters["Azure Virtual Network Name"]
$sslCert = $OctopusParameters["Azure SSLCertificate Thumbprint"]
$caCert = $OctopusParameters["Azure CACertificate Thumbprint"]
$vmName = $OctopusParameters["Azure Vm Name"]
$pathToCSCFG = [System.IO.Path]::Combine($OctopusOriginalPackageDirectoryPath, "ServiceConfiguration.Cloud.cscfg")
$xml = [xml](Get-Content $pathToCSCFG)
if (![string]::IsNullOrEmpty($virtualNetworkName)){