Monday, August 13, 2012

The Following Path Contains More than 259 Characters

There are a number of articles telling you how to reduce the path length through creative mapping (look into the \\?\ syntax). This is an issue when assemblies are gened in a long path structure.

More people need to talk about the creation of .datasource files. These suckers have a default naming convention that concatenates namespace childnamespace sub-childnamespace(n) name.datasource. This is a different issue pointed out by Praphulla Parab These are removable and avoidable.


ISSUE
These get created whenever you add a service reference to a project. These are generated automatically during the generation of the proxy class in the Reference.cs file.

This can easily make the file name lengthier than allowed. If we prefix the path to the file in the Source Control repository hierarchy, the entire path length can easily exceed the TFS 259 character limit. So far the .datasource file does not seem to be a required dependency to build the project.

RESOLUTION
Delete all datasource files and reject .datasource files in your check-in policy.  There is a trick to delete files you have not downloaded locally. Us the tf.exe tool. You must then check in the deletion of the file. Final step is to make a forbidden patterns check in policy using the regex \.datasource$ This is at the scope of the Team Project project definition.Note this is on the Team Project, so it effects everyone.

EG
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE> tf delete $<long path>/file.datasource

Thursday, August 2, 2012

Powershell Deploy Template - Set app_offline.html

#create variables for file names used in move
$hideFile = "app_offline.off.htm"
$liveFile = "app_offline.htm"

#create an array of directories you want to swap files in
$path = @(
"C:\InetPub\Site1"
,"C:\InetPub\Site2"
,"C:\InetPub\Site3"
)

#counters for while loop based on number of directories
#NOTE: Count enumerates from 1. array position enumerates from 0
$maxCnt = $path.Count
$currCnt = 0

#create a log
$logFile = "\temp.txt"
Set-Variable -name log -value $env:userprofile$logFile
if (Test-Path $log) {rm $log}
New-Item $log -type file

#set-variable was used to construct the path due to errors I was getting calling the path and file variables on the fly
#NOTE: Count enumerates from 1. array position enumerates from 0
while ($currCnt -lt $maxCnt)

{
Set-Variable -name currPath -value $path[$currCnt.ToString()]
;  Set-Variable -name hidePath -value $currPath$hideFile
;  Set-Variable -name livePath -value $currPath$liveFile
;  Set-Variable -name currTime -value (Get-Date)
; Move-Item $hidePath  $livePath >> $log
; echo "$currTime moved $hidePath to $livePath"  >> $log
; $currCnt = $currCnt +1
}