Skip to content

Instantly share code, notes, and snippets.

@javiercn
Last active September 16, 2019 15:55
Show Gist options
  • Save javiercn/b774364d0a088ca477802e13601146fb to your computer and use it in GitHub Desktop.
Save javiercn/b774364d0a088ca477802e13601146fb to your computer and use it in GitHub Desktop.
List static web assets
([xml] (Get-Content .\bin\*\*\*.StaticWebAssets.xml)) | 
Select-Object -ExpandProperty StaticWebAssets |
Select-Object -ExpandProperty ContentRoot |
ForEach-Object { 
  $tmpRoot = $_.Path;
  $tmpBase = $_.BasePath;
  Push-Location $tmpRoot;
  Get-ChildItem -Recurse -File $tmpRoot |
  Select-Object -ExpandProperty FullName |
  ForEach-Object { 
    $relativePath = Resolve-Path $_ -Relative;
    $cleanedUpPath = "$tmpBase/$($relativePath.TrimStart('.').Replace('\','/'))";
    $cleanedUpPath = $cleanedUpPath.Replace('//','/');
    [pscustomobject]@{ Path = $_; RelativePath = $cleanedUpPath };
  }
  Pop-Location;
} | Format-List
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment