Trigger an iOS Visual Studio Cordova build form the command line - visual-studio-cordova

I can successfully run a build of the Android app from the command line.
For iOS the build fails using this command line:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com" "<Solution>.sln" /rebuild "Distribution|iOS" /project "<projectName>" /projectconfig "Distribution|iOS"
This is the error:
1>MSBUILD : cordova-build error BLD301: Error : BLD00301 : A remote
iOS build agent has not been configured. Configure one in Tools >
Options > Tools for Apache Cordova > Remote Agent Configuration. For
details and alternatives see
http://go.microsoft.com/fwlink/?LinkID=511904
I have the remote server configured in visual studio but obviously this is not being picked up. Is there a way to feed this configuration into the batch build?

To build your Cordova iOS project under MSBuild, with help of Cordova Tools for Visual Studio. You need to add a property to your MSBuild named iOSRemoteBuildServer. The build command line should looks like this, I am using debug build as an example:
"C:\Program Files (x86)\MSBuild\12.0\Bin\msbuild.exe"
/p:Configuration=Debug
/p:LangName=en-US
/p:Platform=iOS
/p:DebuggerFlavor=iOSRemoteDevice
/p:iOSRemoteBuildServer=http://192.168.0.123:3000
You will find your IPA output at bin\iOS\Debug\ folder.
If MSBuild failed with missing environment variables, the followings should help (assume you are on Cordova Tools CTP3.1 and Node.js 64-bit):
SET MDAVsixDir=%VS120COMNTOOLS%..\IDE\EXTENSIONS\IIC52DPN.UDK
SET NodeJsDir=C:\Program Files\nodejs\
SET NpmInstallDir=%APPDATA%\npm
To set a security PIN for retrieving the client certificate, you can use MSBuild property iOSRemoteBuildSecurityPIN but I have not tested this property yet.

Please note that you need to start the remote agent on your Mac machine, get the IP/host, the port and the pin and configure it using Tools --> Options --> Tools for Apache Cordova in VS, before you can initiate the build. Visual studio wouldn't start the remote server for you.
The process to setup the remote agent is explained at https://msdn.microsoft.com/en-us/library/dn771551.aspx.

Related

dotnet build stopped working after VS 2022 upgrade

I upgraded Visual Studio Community to the final release, and it stopped working. Specifically, I could generate a new project, but when I try to load it, it gave me an error
Critical Project 'SdkTest' load failed| [MSB4236] The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. ...\SdkTest.csproj
Even though build and run worked fine
I ran "repair" on VS2022, and it seems to be working now from Visual Studio. However, dotnet --info doesn't show any SDKs; only runtime; and dotnet build or dotnet new give an error:
C:\Code>dotnet new console -o myapp
Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
* You intended to execute a .NET program:
The application 'new' does not exist.
* You intended to execute a .NET SDK command:
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
https://aka.ms/dotnet-download
I even reinstalled .NET 6 and I see it in the list of applications (along with older SDKs). I checked the path, and I see everything that I expect to see:
C:\Program Files (x86)\dotnet\
C:\Program Files\dotnet\
C:\Users\me\.dotnet\tools
I am running Windows 11.
It's known bug in VS2022 installation.
Problem is that dotnet you access is located inside Program Files(x86)/dotnet, but all sdk's are located in Program Files/dotnet. You simply need to edit PATH environment variable so Program Files/dotnet goes before Program Files(x86)/dotnet. If you don't see Program Files(x86)/dotnet in user environment variable (which is likely to happen) then edit system environment variable (located below)
Example with screenshots: https://stackoverflow.com/a/44272417/10339675

How do I use Visual Studio 2019 to remotely debug a .NetCore application on a Hyper-V Linux VM?

I am attempting to remotely debug a .NetCore application in Ubuntu Linux from Visual Studio 2019 in Windows 10. I can see the remote ipaddress (ping thru command line). I can RDT to the ipaddress. I can successfully transfer files to it via WinSCP.
I created a simple .NetCore "HelloWorld" app and copied onto the Linux VM.
I used the following commands to build and publish:
dotnet build -r linux-x64
dotnet publish --self-contained -r linux-x64
I ran the following command on the Linux VM to ensure that ssh is functional:
sudo apt-get install openssh-server unzip curl
The app is running on Linux.
From VS I try to attach to the process:
I get prompted for logon:
I get the following error:
Is there a step I'm missing somewhere?
Is there a configuration/permissions issue I am unaware of?
Thanks, JohnB
Microsoft has documented debugging a Linux target from a Windows development machine at https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-dotnet-core-linux-with-ssh?view=vs-2022
Unfortunately, using that method, you will need to manually deploy and manually attach the debugger. If you'd like Microsoft to change that, then it would be wise to upvote this issue: https://developercommunity.visualstudio.com/t/Convenient-way-to-add-a-remote-debug-con/917516
A 3rd party developer has created a Visual Studio extension that provides this missing feature to Visual Studio. It can be downloaded from https://github.com/radutomy/VSRemoteDebugger
I had the same problem initially because I didn't enter the connection target in the first screen.
After having entered the correct target myusername#192.168.178.95 in the first screen the second screen did not show up any longer and I got the expected list of processes

Running Angular 4 + Core 2.0 on IIS failing to start up

I have an application written in ASP.Net Core 2.0 using the Visual Studio Angular 2 template that I can run successfully on my local IIS installation and local commandline but fails on Windows Server 2012 R2 Standard.
From my local command line I can run:
dotnet myApp.dll
And the application runs successfully until ASP.Net core 2.0. When I copy the deployed application to my 2012 server (where the Core 2.0 runtime as been installed), I cannot call the same dotnet command (both calls are from within the root deployment folder for the app myApp).
On my desktop, the result is a web site that is listening at 5000 (ASP.Net core 2's default port I'm assuming) when running from the published site locations.
However, when I run this same command on the server, I get the error:
Unhandled Exception: System.AggregateException: One or more errors occurred. (We
bpack dev middleware failed because of an error while loading 'aspnet-webpack'.
Error was: Error: Cannot find module 'aspnet-webpack'....
....
....
) ---> Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException:
Webpack dev middleware failed because of an error while loading 'aspnet-webpack'
. Error was: Error: Cannot find module 'aspnet-webpack'
When I look up aspnet-webpack from npmjs.com, I note that this module is "This NPM package is an internal implementation detail of the Microsoft.AspNetCore.SpaServices NuGet package" according to NPM.
I'm assuming that somehow my Core 2.0 install in missing or not able to reference Microsoft.AspNetCore.SpaServices, but at this point I'm not sure where I should be looking for this.
Thanks for any input.
Look at your system variables (right click My PC > Properties > Environment Variables). ASPNETCORE_ENVIRONMENT has to be set to either Staging or Production if you do not have the dotnet sdk installed.
Once you change that value, change it in your project (Properties > Debug tab) as well. Redeploy your project and restart your server. You should see the site working now.
Good luck!

VSTS Build failing - Error : Web deployment task failed

I have a build definition in Visual Studio Team Services (previously Visual Studio Online) to build an ASP.NET web application using an on-premise agent. The agent has VS2012 installed and all the other necessary prerequisites to assist in building the application. However, when running the build, it fails and outputs below error:
C:\Program Files
x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4021,2):
Error : Web deployment task failed. (The .zip file package
'C:\BuildAgent\_work\1\a\' must be a file, not a directory.)
Process 'msbuild.exe' exited with code '1'.
I tried building the project on the agent machine using VS2012 and it builds fine. Also, I have defined following MSBuild parameters in the build definition which is same as my other builds that use a hosted agent:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
What could be the cause of this issue? Do I need to install anything extra?
You are using VS2012, you need to specify detail PackageLocation argument with .zip suffix ($(build.artifactstagingdirectory)\testWeb.zip). If you are using higher version of VS/MSBuild (e.g. vs 2015), a folder path is ok, it will adds [XXX].zip to the end of that path.

Web Deploy script error - msdeploy.exe is not found on this machine

I'm trying to execute a web deploy script on a clean build Windows Server 2008 R2 machine and getting the following error:
ERROR: The system was unable to find the specified registry key or
value. msdeploy.exe is not found on
this machine. Please install Web
Deploy before execute the script.
The package was created in VS2010 and executes fine on my development box (as always!). If I import the package on the server through IIS everything works fine.
Web Deploy has been installed on the server through the Web Deployment Tool 2.1 via the Web P.I and I've verified the inclusion of msdeploy.exe. I'm running the script through the "IIS Extensions/Web Deploy Command Line" start menu item so I'm guessing that the correct paths should be set. I've also tried it as Administrator with the same error.
Any help greatly appreciated.
Copied from here:
There is an error with the way Microsoft’s Web Deploy 2.1 application creates command line packages from Visual Studio 2010.
If you create a package to publish and then try to run the msdeploy.exe command line publishing tool it on a production server running IIS then you may receive the following error:
ERROR: The system was unable to find the specified registry key or
value. msdeploy.exe is not found on this machine. Please install Web
Deploy before execute the script.
Assuming that you actually have installed Web Deploy from http://www.iis.net/download/WebDeploy then the error may be caused by an incorrect registry path variable in the .cmd file that Visual Studio creates.
Open up the .deploy.cmd file that is part of your deployment package in a text editor and look for the following code block:
if "%MSDeployPath%" == "" (
for /F "usebackq tokens=2*" %%i in
(`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1" /v InstallPath`)
do (if "%%~dpj" == "%%j" (
set MSDeployPath=%%j
If you have installed Web Deploy 2.0 or higher, then the error is caused by the registry query to HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1. If you open up regedit on your production server you’ll find that the appropriate key is actually HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\2.
Change the reference in the.deploy.cmd file and you’ll be able to successfully run the deployment package.
I have the same problem. Installed WebDeploy_2_10_amd64_en-US. Running the Deploy Command Line I get the same erorr. However, in IIS (version 7) I could use an option import application. With this option (right side of the window in the actions toolbar) I was able to import the application deployment package zip file. All settings were imported correctly except for the application pool. I only had to adjust that and everything was running fine.

Resources