Im trying to run jss cli commands (Windows Powershell) from my C# Class. I`m creating the commands dynamically, but i noticed that jss commands are not running.
PowerShell ps = PowerShell.Create();
//Call Powershell
foreach (var item in scripts)
{
ps.AddScript(item);
}
Collection<PSObject> results = ps.Invoke();
This is the code to create the scripts dynamically:
//Name of Component
var nameofComponent = definitonArchive.Name.Replace(".sitecore.js", "");
var locationSystem = Sitecore.Configuration.Settings.GetSetting("X:JSSApplicationFolder");
//Add location command
PowerShellCommands.Add($"Set-Location -Path {locationSystem}");
//Create the JSS manifest command
var jssManifestCommand = String.Format("jss manifest --manifestSourceFiles '{0}'", definitonArchive.FullName.Replace("/", @"\"));
PowerShellCommands.Add($"Invoke-Expression \"{jssManifestCommand}\"");
//Add build command
var jssDeployCommand = "jss deploy app --includeContent --includeDictionary";
PowerShellCommands.Add($"Invoke-Expression \"{jssDeployCommand}\"");
I noticed that nothing was happening, however using a console application with the same logic, everything works fine.
I created another command just to create a txt file, in purpose to test, and works fine.
//To test
PowerShellCommands.Add(@"New-Item C:\temp\test.txt");
I also created a log to check if the scripts are with a correct syntax, and they are good.
I noticed the error i`m receiving is:
The term 'jss' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
m receiving is: The term 'jss' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. Its weird because if I run the same command that I
m running but manually, works perfectly.