PoshCode Archive  Artifact [0f14552767]

Artifact 0f14552767a2b6c7696065e1d0c961cf47f163d3f904d2ff958deadff9fa13c0:

  • File Get-ExcludedCsprojJavasc.ps1 — part of check-in [a75a024fc9] at 2018-06-10 13:31:40 on branch trunk — 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. (user: George Mauer size: 1398)

# 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