Find .NET Core packages in all projects

In a quick aide-memoire for next time I need to use it: here’s a Powershell snippet that will return a list of all unique package names in all .NET Core projects under the current folder:

get-childitem -recurse -filter *.csproj |
  foreach { get-content $_.FullName } |
  select-string -pattern "PackageReference Include=""(.+?)""" |
  % { $_.matches[0].Groups[1].Value } |
  sort-object -unique

Line by line…

  • Get all *.csproj in the current and child folders
  • Read the content of each one
  • Extract every line that matches the specific regex and extract the name of the package
  • Grab the package name group
  • Sort & filter to unique values

This outputs something like

CommandLineParser
CsvHelper
Microsoft.Extensions.DependencyInjection
Microsoft.Extensions.Logging
Microsoft.Extensions.Logging.Console
Advertisements

Chrome Dev Tools & Inline Dynamic JavaScript

If you are using Chrome dev tools to debug your application then you might have come across this situation.  If you dynamically load some content, and that content contains an inline <script> tag, then annoyingly you can’t see that script under Source in the developer console.

Thankfully there’s a nice simple solution to the problem: insert the following tag at the end of your inline script:

<script>
    //...
    //@ sourceURL=MyInlineScript.js
</script>

This will make the script appear in the Sources list under the “No Domain” section:

InlineScript

Remember that if the inline script is part of a Razor view then you will need to escape the @

<script>
    //...
    //@@ sourceURL=MyInlineScript.js
</script>

Update

Since this post was first written the syntax has been changed to use //#

<script>
    //...
    //# sourceURL=MyInlineScript.js
</script>