csproj - TFS: How to validate if every file is checked-in? -
we working on several asp.net mvc c# projects within visual studio 2015 , team foundation server 2013. nuget upgrade process mess , of replaced files (mostly *.png, *.gif, *.ttf) have not been checked-in properly. have figured out far: check-in process gets trouble, if directories should removed , created in 1 step. have check-in twice. problem is, if don’t know , 1 of our developers retrieves latest source, there missing files. visual studio indicates warning icon in solution explorer.
my question is: possible validate, if every file present during gated-checkin or nightly-build on tfs linked in csproj file? @ least there should warning during build.
hint: problem files, not compiled (*.cs files) or not have setting “copy during build output directory”. happens e.g. js-files, bundled.
final solution:
write-host "check availability referenced files in projects ..." function check-files($directory, $files){ if (!$directory.endswith("/")) { $directory = "$($directory)/" } foreach($file in $files){ if($file){ write-host " referenced file $($directory)$file" if(-not (test-path "$($directory)$($file)")){ throw [system.io.filenotfoundexception] "$($directory)$($file) not found." } } } } function checkprojectfile($csprojfile){ [xml]$projectcontent = get-content $csprojfile write-host "checking project: $($csprojfile) ..." $directory = split-path $csprojfile foreach($itemgroup in $projectcontent.project.itemgroup){ check-files -files $itemgroup.reference.hintpath -dir $directory check-files -files $itemgroup.compile.include -dir $directory check-files -files $itemgroup.none.include -dir $directory check-files -files $itemgroup.content.include -dir $directory check-files -files $itemgroup.typescriptcompile.include -dir $directory check-files -files $itemgroup.projectreference.include -dir $directory } } $csprojfiles = get-childitem -path ./ -recurse *.csproj | select-object -property fullname foreach($file in $csprojfiles){ checkprojectfile($file.fullname) }
i added script file team project on tfs, changed build definition, added script directory "source settings" , included script "pre-build script path". done!
i created small piece of powershell can execute step before building solution.
function check-files($files){ foreach($file in $files){ if($file){ write-host "looking $file" if(-not (test-path $file)){ throw [system.io.filenotfoundexception] "$file not found." } } } } [xml]$projectcontent = get-content ./your.csproj foreach($itemgroup in $projectcontent.project.itemgroup){ check-files -files $itemgroup.reference.hintpath check-files -files $itemgroup.compile.include check-files -files $itemgroup.none.include check-files -files $itemgroup.content.include check-files -files $itemgroup.typescriptcompile.include check-files -files $itemgroup.projectreference.include }
hope helps you. kind regards jan
Comments
Post a Comment