Service Fabric: pkg\Debug is not found - azure

I have created Service Fabric Application and added Stateless ASP.NET Core Web API 3.1 project into it. When I run the Service Fabric Application locally using VS 2019, I am getting the below error:-
The PowerShell script failed to execute. See the Service Fabric Tools pane in the output window for details.
Bellow is the output window info
C:\Users\malle\Documents\Mahesh\Projects\RetentionPortal\API\Application1\pkg\Debug is not found.
At C:\Program Files\Microsoft SDKs\Service
Fabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:120 char:9
+ throw $errMsg
+ ~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (C:\Users\malle\...g is not found.:String) [], RuntimeException
+ FullyQualifiedErrorId : C:\Users\malle\Documents\Mahesh\Projects\RetentionPortal\API\Application1\pkg\Debug is n
ot found.
Finished executing script 'Publish-NewServiceFabricApplication'.
Time elapsed: 00:00:01.7629461
Started executing script 'Unpublish-ServiceFabricApplication'.
powershell -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command "[void](Connect-ServiceFabricCluster); Import-Module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\ServiceFabricSDK.psm1'; Unpublish-ServiceFabricApplication -ApplicationName 'fabric:/Application1' -ErrorAction Stop"
Removing application...
Finished executing script 'Unpublish-ServiceFabricApplication'.
Time elapsed: 00:00:01.5278716
Started executing script 'UnregisterApplicationType'.
powershell -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command "[void](Connect-ServiceFabricCluster); Import-Module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\ServiceFabricSDK.psm1'; if (Get-ServiceFabricApplicationType -ApplicationTypeName 'Application1Type' | Where-Object { $_.ApplicationTypeVersion -eq '1.0.0' }) { Unregister-ServiceFabricApplicationType -ApplicationTypeName 'Application1Type' -ApplicationTypeVersion '1.0.0' -ErrorAction Stop -Force }"
Finished executing script 'UnregisterApplicationType'.
Time elapsed: 00:00:01.4425472
Any help is really appreciated

General solution steps:
Reboot Computer
Log On
Start Visual Studio as Admin
Open Service Fabric Project
F5 to Debug
Try to run the same project again, same output
Run POwerShell as Admin, Connect-ServiceFabricCluster.
Start debugging (F5) in Visual Studio
Everything's fine now
For more details, you can check the issues oin github.
Publish-NewServiceFabricApplication fails to read ApplicationManifest.xml
If the above solution does not work, it is recommended to try the following steps.
Create pkg/Debug folder.
I have some files under Debug folder, so I deleted them.
Clean and Rebuild Solution.
F5 Run. It will generate files you want.

Related

How to run PowerShell cmdlets from custom PS modules when deploying a new Azure VM?

Is it possible to install a custom PowerShell module in Azure VM post-deployment task and run PS cmdlets from that module in this task?
I have a Bicep template that deploys a new Windows Azure VM. The template has a Microsoft.Compute/virtualMachines/extensions#2020-12-01 post-deployment resource that takes these steps:
Installs an MSI-packaged application (with a new custom PowerShell module) using Start-Process (OK)
Creates several folders via PowerShell (OK)
Runs several cmdlets installed at step 1 (NOT OK)
Running a cmdlet from the custom module in the post-deployment script shows the following error in the "Extensions + applications" log:
... is not recognized as the name of a cmdlet ...
When I change the post-deployment step to Import-Module MODULENAME, I see another message:
Import-Module : The specified module 'MODULENAME' was not loaded because no valid module file was found in any module \r\ndirectory.
When I run Get-Module in the post-deployment task, I see only these two modules listsd:
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
So the module is not getting loaded.
But when I remote to the deployed VM, I run the cmdlets from the custom PowerShell module without any errors.
I think that my scenario is supported, but I don't quite understand how to troubleshoot this further.
I resolved the problem with these two steps:
I've added -Wait to Start-Process and this has resolved the problem.
I've added a path to the module into PSModulePath and ran $Env:PSModulePath = $Env:PSModulePath+";PATH-TO-MODULE"
Import-Module MODULENAME -Force. Normally, the installed does this step for me. But it appears that I need to run these commands manually because all this is done in a single PowerShell session.
It appears that the problem was with my customScript.ps1 script. The very first line of the script installs an MSI-packaged application that adds the required PowerShell module:
Start-Process -FilePath msiexec.exe -ArgumentList #('/i', 'msi-installer-name.msi', '/qb')
PowerShell starts the installation using Start-Process and continues. So when I'm running these commands, the installation hasn't yet finished:
$env:PSModulePath | Out-File C:\Temp\psmodulepath.txt
Get-Module -ListAvailable | Out-File C:\Temp\getmodulelistavailable.txt

Unable to install ios and android requirements in windows-10

I am running below command using CMD(as administrator) provided in to document (In Full setup section - Step-2),
#powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))"
but getting below exception,
Exception calling "DownloadString" with "1" argument(s): "The request was aborted: Could not create SSL/TLS secure channel."
At line:1 char:1
After doing some google search, I found that I need to change the security protocol to Tls1.2, so tried to fire same command using Windows PowerShell(as administrator) after adding the protocal Tls1.2,
First command to add Tls1.2,
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
second same command which I ran on CMD,
#powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))"
but by using PowerShell, I got below,
I would appreciate if you can help me with this.
After you set the SecurityProtocolType in Powershell, simply execute this in Powershell as well:
iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))

Error while applying configuration using PowerShell DSC VM extension : "Compilation errors occurred while processing configuration"

I have a simple configuration that I am trying to apply to an Azure VM using PowerShell DSC extension
Configuration DSCTest
{
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Import-DscResource -ModuleName xPSDesiredStateConfiguration
Node "localhost"
{
File ESETInstaller
{
Type = 'Directory'
DestinationPath = 'C:\ESETInstaller'
Ensure = "Present"
}
}
}
DSCTest
I've published this using
Publish-AzVMDscConfiguration "D:\Test\DSCTest.ps1" -OutputArchivePath "D:\Test\DSCTest.ps1.zip"
and then I uploaded this zip file in Azure BLOB storage.
After that, I tried to apply this configuration to a VM using the following command:
Set-AzVMDscExtension -ResourceGroupName 'TestDSC' -VMName 'TestDSCVM' -ArchiveStorageAccountName 'test***********' -ArchiveResourceGroupName '******' -ConfigurationName $configurationName -ArchiveBlobName "DSCTest.ps1.zip" -ArchiveContainerName 'dsc' -Name "DSCTest" -Version 2.76
In the target machine, I can see that the DSC folder appears
But on the console I get the error:
Although, I am able to successfully apply the configuration in the target machine by manually executing the command from inside that VM.
Please let me know if anyone has ever faced this issue before. Thanks.
The logs inside the target machine showed that the issue is with the execution policy.
In my script I changed "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned" to "Set-ExecutionPolicy -ExecutionPolicy ByPass -Scope CurrentUser -Force" and it worked fine.

Azure DevOps build pipeline with hosted agent failing

I am pretty new to Azure and TFS and related. So please excuse me if I mix up the terms here.
I am testing the capabilities of Microsoft Team Foundation Server with an on-premise installation. I am not the admin of the server itself, I have admin access to one of the projects inside.
I have a git repo with some python code in this project and I am trying to set up CI build pipeline for this. I am also manually configuring an agent to run this build pipeline. For the timebeing, I am configuring the windows machine that I am working on to run as an agent. I was able to set it up to listen for jobs and also it picks up the job when submitted from the TFS server. (I am running the agent from a cmd.exe window)
However, I couldn't get it do even the simplest of command line tasks as part of the build pipeline.
Below is the output of where python:
2019-08-27T14:41:15.1614046Z ##[section]Starting: Find python version
2019-08-27T14:41:15.1623937Z ==============================================================================
2019-08-27T14:41:15.1624042Z Task : Command Line
2019-08-27T14:41:15.1624091Z Description : Run a command line script using cmd.exe on Windows and bash on macOS and Linux.
2019-08-27T14:41:15.1624157Z Version : 2.146.1
2019-08-27T14:41:15.1624203Z Author : Microsoft Corporation
2019-08-27T14:41:15.1624258Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
2019-08-27T14:41:15.1625058Z ==============================================================================
2019-08-27T14:41:15.6151701Z Cannot invoke method. Method invocation is supported only on core types in this language mode.
2019-08-27T14:41:15.6151921Z At line:1 char:1
2019-08-27T14:41:15.6151968Z + . ([scriptblock]::Create('if (!$PSHOME) { $null = Get-Item -LiteralPa ...
2019-08-27T14:41:15.6152019Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-08-27T14:41:15.6152077Z + CategoryInfo : InvalidOperation: (:) [], RuntimeException
2019-08-27T14:41:15.6152123Z + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
2019-08-27T14:41:15.6152156Z
2019-08-27T14:41:17.7569608Z Cannot invoke method. Method invocation is supported only on core types in this language mode.
2019-08-27T14:41:17.7569833Z At line:1 char:740
2019-08-27T14:41:17.7570630Z + ... Continue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create ...
2019-08-27T14:41:17.7571090Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-08-27T14:41:17.7572452Z + CategoryInfo : InvalidOperation: (:) [], RuntimeException
2019-08-27T14:41:17.7574051Z + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
2019-08-27T14:41:17.7574178Z
2019-08-27T14:41:17.8271008Z ##[error]Exit code 1 returned from process: file name 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe', arguments '-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create('if (!$PSHOME) { $null = Get-Item -LiteralPath ''variable:PSHOME'' } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1'')) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1'')) }')) 2>&1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; Import-Module -Name 'C:\TOOLS\agent\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9\2.146.1\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1' -ArgumentList #{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = 'SilentlyContinue' ; $DebugPreference = 'SilentlyContinue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''C:\TOOLS\agent\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9\2.146.1\cmdline.ps1'''))"'.
2019-08-27T14:41:17.8301183Z ##[section]Finishing: Find python version
This command runs fine when I execute it from a commandline interactively in my machine.
Why is the PowerShell getting invoked when the pipeline runs? And why such a long command to execute something so simple?
Thanks in advance for any suggestions you can give.
The agent uses PowerShell behind the scenes, it looks like your IT put some security in the computers that blocked running some PowerShell scripts (maybe only it from remote).
Try to run it in your PowerShell:
$ExecutionContext.SessionState.LanguageMode
I guess you will get this output:
ConstrainedLanguage
If yes, try to switch it to FullLanguage:
$ExecutionContext.SessionState.LanguageMode = "FullLanguage"
If it doesn't help maybe it's also blocked, so you need to talk with IT that will change it or try to change the registry like explained here or set the environment variable __PSLockdownPolicy to 0.

Running powershell from azure startup task

In my ServiceDefinition.csdef file I have this:
<Startup>
<Task commandLine="powershell -ExecutionPolicy Unrestricted -command "Install-WindowsFeature Net-Framework-Core"" taskType="simple" executionContext="elevated"/>
</Startup>
But when I try to publish it to azure I get:
Cannot find file named 'approot\bin\powershell' for startup task powershell -ExecutionPolicy Unrestricted -command "Install-WindowsFeature Net-Framework-Core" of role WebRole.
I'm trying to run powershell so I can install .net 3.5 is OS family "3" (windows 2012). That command runs fine from a cmd line while remoted into my instance.
What's the correct syntax to run powershell?
I got it to work with some help from Michael Volodarsky.
create a file called "install35.cmd" in the "Startup" folder:
powershell -ExecutionPolicy Unrestricted -command "Install-WindowsFeature Net-Framework-Core"
exit 0
Save as / advanced / set codepage to windows 1252
In solution explorer, right click and set build type=content, copy always
In startup tasks, add:

Resources