SlowCheetah failing quietly.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- powershell
- Domain
- documentation
Research direction
Start by reproducing the PowerShell example at the TransformConfig entry point and inspect how TransformerFactory and the logging stub are used. The issue names no repository files or tests, so first determine whether the missing guidance or the silent transformation failure is the intended scope. Done should include documented, supported PowerShell usage and an actionable explanation of failures.
Written by the indexing model from the issue text.
Description
Hello all. First, my issue could very well be solved if I could find the correct and complete documentation for slow cheetah usage, specifically in PowerShell.
I'm trying to add the ability to transform json config files via powershell for use in certain cases (but not ALL environments/situations, so adding this to source/project files is not an option).
I'm able to do this exact same thing using XDT for web.config files in other builds, so I know its possible with the correct usage.
So far, I'm able to get all the way to the point where the transform should occur, but then get an error that is completely silent other than 'false'.
I was able to find someones example on stack exchange (https://stackoverflow.com/questions/62944828/can-you-run-microsoft-visualstudio-slowcheetah-from-powershell), which has been modified/simplified to eliminate issues. I'm left with this:
function GetNuget(){
process{
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
'Downloading nuget.exe' | Write-Verbose
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', "$env:LOCALAPPDATA\NuGet\BuildTools\nuget.exe")
return "$env:LOCALAPPDATA\NuGet\BuildTools\nuget.exe"
}
}
function GetNugetPackage(){
if(!(Test-Path "$env:LOCALAPPDATA\NuGet\BuildTools\")){
New-Item -Path "$env:LOCALAPPDATA\NuGet\BuildTools\" -ItemType Directory | Out-Null
}
$cmdArgs = @(
'install',
'Microsoft.VisualStudio.SlowCheetah',
'-OutputDirectory',
(Resolve-Path "$env:LOCALAPPDATA\NuGet\BuildTools\").ToString()
)
&(GetNuget `
-toolsDir "$env:LOCALAPPDATA\NuGet\BuildTools\" `
-nugetDownloadUrl 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe') `
$cmdArgs | Out-Null
$toolPath = (
Get-ChildItem `
-Path "$env:LOCALAPPDATA\NuGet\BuildTools\" `
-Include 'Microsoft.VisualStudio.SlowCheetah.dll' `
-Recurse
) | Select-Object -First 1
return $toolPath
}
function TransformConfig{
[cmdletbinding()]
param(
[Parameter(
Mandatory=$true,
Position=0)]
$sourceFile,
[Parameter(
Mandatory=$true,
Position=1)]
$transformFile,
[Parameter(
Mandatory=$true,
Position=2)]
$destFile,
$toolsDir = "$env:LOCALAPPDATA\NuGet\BuildTools\"
)
process{
$sourcePath = (Resolve-Path $sourceFile).ToString()
$transformPath = (Resolve-Path $transformFile).ToString()
$cheetahPath = GetNugetPackage `
-packageName 'Microsoft.VisualStudio.SlowCheetah' `
-toolFileName 'Microsoft.VisualStudio.SlowCheetah.dll' `
-toolsDir "$env:LOCALAPPDATA\NuGet\BuildTools\"
[Reflection.Assembly]::LoadFrom($cheetahPath.FullName) | Out-Null
Add-Type -TypeDefinition $loggingStubSource -Language CSharp -ReferencedAssemblies $cheetahPath.FullName
$logStub = New-Object Microsoft.VisualStudio.SlowCheetah.LoggingStub
$transformer = [Microsoft.VisualStudio.SlowCheetah.TransformerFactory]::GetTransformer($sourcePath, $logStub);
$transformer.Transform($sourcePath, $transformPath, $destFile);
}
}
$loggingStubSource = @"
using System;
namespace Microsoft.VisualStudio.SlowCheetah
{
public class LoggingStub : ITransformationLogger
{
public void LogError(string message, params object[] messageArgs) { }
public void LogError(string file, int lineNumber, int linePosition, string message, params object[] messageArgs) { }
public void LogErrorFromException(Exception ex) { }
public void LogErrorFromException(Exception ex, string file, int lineNumber, int linePosition) { }
public void LogMessage(LogMessageImportance importance, string message, params object[] messageArgs) { }
public void LogWarning(string message, params object[] messageArgs) { }
public void LogWarning(string file, int lineNumber, int linePosition, string message, params object[] messageArgs) { }
}
}
"@
TransformConfig -sourceFile $sourceFile -transformFile $transformFile -destFile $destFile
I would appreciate, above all else, links to docs explaining proper usage. Understanding and being able to implement this more properly is ideal, but any help is welcome.
- Dominant language
- PowerShell
- Stars
- 116
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/json-document-transforms
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
-
Release requestOpen
Difficulty 3/5 1-2 days Newbie friendliness 25/100
microsoft/json-document-transforms#27 · 1 reaction ·
All issues in microsoft/json-document-transforms
Similar issues
-
Code Cleanup Dev Environment
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ProjectSidewalk/SidewalkWebpage#5699 ·
Maintainers usually reply within 1 day
-
area/install documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
community documentation first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 70/100
lingdojo/kana-dojo#31864 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
climate-analytics-lab/jax-gcm#1057 ·
Maintainers usually reply within 1 day