# encoding: ascii
# api: powershell
# title: Get-ExcludedCsprojJavasc
# description: Do you create javascripts outside of visual studio and are constantly forgetting to include them? Does that break your deployments or automated build? This script will check your csproj file and your scripts directory and let you know which javascripts are missing from your csproj.
# version: 0.1
# type: script
# author: George Mauer
# license: CC0
# x-poshcode-id: 3821
# x-archived: 2012-12-16T04:26:07
# x-published: 2012-12-13T07:56:00
#
# Assumes a structure of
# Solution
# HelperScripts
# Get-ExcludedCsprojJavascripts.ps1
# MyProject
# MyWebProject.csproj
# Scripts
# jquery.js
# script1.js
#
param(
$projectDirectoryName = "MyProject"
)
$thisDir = Split-Path $MyInvocation.MyCommand.Path
$projectDir = "$thisDir/../$projectDirectoryName"
$csproj = [xml](cat $projectDir/*.csproj)
$csprojScripts = $csproj.Project.ItemGroup.Content.Include | ? {$_ -match '\.js$'}
"$($csprojScripts.length) scripts included in csproj file"
$scripts = ls $projectDir -rec -inc *.js
$scripts = $scripts.FullName | % {($_ -match "$projectDirectoryName\\(.*)" | out-null); $matches[1]}
"$($scripts.length) scripts contained in scripts directory"
$diff = $scripts |? {-not ($csprojScripts -contains $_)}
"Scripts in directory but not in csproj:"
$diff
return $diff.length