I use nuget-tree to inspect the nuget dependencies in our code. It produces output like this:
C:\xyz\tip [master ≡]> $p |? { Test-Path "$_\..\packages.config" } | select -First 1 |% { pushd "$_\.."; "$_" ; nuget-tree.cmd --showSystem ; popd }
C:\xyz\tip\BI\a8i\a8i.csproj
packages.config
└── Newtonsoft.Json 11.0.2
C:\xyz\tip [master ≡]>
I would like to save the output to file, but I can't figure out what encoding to use to preserve the nice hierarchy ascii art. Please, observe:
C:\xyz\tip [master ≡]> $p |? { Test-Path "$_\..\packages.config" } | select -First 1 |% { pushd "$_\.."; "$_" ; nuget-tree.cmd --showSystem ; popd } | Out-File c:\temp\1.txt ; cat c:\temp\1.txt
C:\xyz\tip\BI\a8i\a8i.csproj
packages.config
ΓööΓöÇΓöÇ Newtonsoft.Json 11.0.2
C:\xyz\tip [master ≡]> $p |? { Test-Path "$_\..\packages.config" } | select -First 1 |% { pushd "$_\.."; "$_" ; nuget-tree.cmd --showSystem ; popd } | Out-File c:\temp\1.txt -Encoding ascii ; cat c:\temp\1.txt
C:\xyz\tip\BI\a8i\a8i.csproj
packages.config
????????? Newtonsoft.Json 11.0.2
C:\xyz\tip [master ≡]> $p |? { Test-Path "$_\..\packages.config" } | select -First 1 |% { pushd "$_\.."; "$_" ; nuget-tree.cmd --showSystem ; popd } | Out-File c:\temp\1.txt -Encoding unicode ; cat c:\temp\1.txt
C:\xyz\tip\BI\a8i\a8i.csproj
packages.config
ΓööΓöÇΓöÇ Newtonsoft.Json 11.0.2
C:\xyz\tip [master ≡]> $p |? { Test-Path "$_\..\packages.config" } | select -First 1 |% { pushd "$_\.."; "$_" ; nuget-tree.cmd --showSystem ; popd } | Out-File c:\temp\1.txt -Encoding utf8 ; cat c:\temp\1.txt
C:\xyz\tip\BI\a8i\a8i.csproj
packages.config
ΓööΓöÇΓöÇ Newtonsoft.Json 11.0.2
C:\xyz\tip [master ≡]>
How can it be done (except for copy/paste of the console window content) ?