Dejulia489 / WindowsServiceManager

https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager
MIT License
11 stars 9 forks source link

Setup #23

Closed jamesebaker63 closed 4 years ago

jamesebaker63 commented 4 years ago

This is my log file. I am not sure what I need to do to set it up correctly. I am trying to install the service on the same machine as I build it on. I installed WinRM and have it working correctly, but am unsure what needs to be set. If you could give an example setup it would be very helpful. This is my logfile:

2019-10-30T03:10:31.2450171Z ##[section]Starting: Release 2019-10-30T03:10:31.2483735Z Current agent version: '2.136.1' 2019-10-30T03:10:31.5513719Z ##[section]Starting: Initialize Job 2019-10-30T03:10:31.5555093Z Prepare release directory. 2019-10-30T03:10:31.5565443Z ReleaseId=7, TeamProjectId=f593a1cf-2f36-4f02-ae59-d63a1e7c7691, ReleaseDefinitionName=New Release Definition 2019-10-30T03:10:31.5657020Z Release folder: C:\agent_work\r2\a 2019-10-30T03:10:31.5839069Z Environment variables available are below. Note that these environment variables can be referred to in the task (in the ReleaseDefinition) by replacing "_" with "." e.g. AGENT_NAME environment variable can be referenced using Agent.Name in the ReleaseDefinition: [AGENT_HOMEDIRECTORY] --> [C:\agent] [AGENT_ID] --> [1] [AGENT_JOBNAME] --> [Release] [AGENT_MACHINENAME] --> [JAMES-PC] [AGENT_NAME] --> [JAMES-PC] [AGENT_OS] --> [Windows_NT] [AGENT_RELEASEDIRECTORY] --> [C:\agent_work\r2\a] [AGENT_ROOTDIRECTORY] --> [C:\agent_work] [AGENT_SERVEROMDIRECTORY] --> [C:\agent\externals\vstsom] [AGENT_TEMPDIRECTORY] --> [C:\agent_work_temp] [AGENT_TOOLSDIRECTORY] --> [C:\agent_work_tool] [AGENT_VERSION] --> [2.136.1] [AGENT_WORKFOLDER] --> [C:\agent_work] [AZURE_HTTP_USER_AGENT] --> [TFS_273478af-6df4-411c-852f-bb4873d309ba_release_2_7_7_2] [BUILD_BUILDID] --> [84] [BUILD_BUILDNUMBER] --> [20191029.5] [BUILD_BUILDURI] --> [vstfs:///Build/Build/84] [BUILD_DEFINITIONID] --> [7] [BUILD_DEFINITIONNAME] --> [MathWin-.NET Desktop-CI] [BUILD_PROJECTID] --> [f593a1cf-2f36-4f02-ae59-d63a1e7c7691] [BUILD_PROJECTNAME] --> [MathWin] [BUILD_REPOSITORY_ID] --> [f593a1cf-2f36-4f02-ae59-d63a1e7c7691] [BUILD_REPOSITORY_NAME] --> [MathWin] [BUILD_REPOSITORY_PROVIDER] --> [TfsVersionControl] [BUILD_REQUESTEDFOR] --> [James Baker] [BUILD_REQUESTEDFORID] --> [8826a6f1-30f9-48d5-9fbf-8369c1153ff5] [BUILD_SOURCEBRANCH] --> [$/MathWin] [BUILD_SOURCEBRANCHNAME] --> [MathWin] [BUILD_SOURCEVERSION] --> [43] [BUILD_TYPE] --> [Build] [MSDEPLOY_HTTP_USER_AGENT] --> [TFS_273478af-6df4-411c-852f-bb4873d309ba_release_2_7_7_2] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_BUILDID] --> [84] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_BUILDNUMBER] --> [20191029.5] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_BUILDURI] --> [vstfs:///Build/Build/84] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_DEFINITIONID] --> [7] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_DEFINITIONNAME] --> [MathWin-.NET Desktop-CI] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_PROJECTID] --> [f593a1cf-2f36-4f02-ae59-d63a1e7c7691] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_PROJECTNAME] --> [MathWin] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_REPOSITORY_ID] --> [f593a1cf-2f36-4f02-ae59-d63a1e7c7691] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_REPOSITORY_NAME] --> [MathWin] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_REPOSITORY_PROVIDER] --> [TfsVersionControl] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_REQUESTEDFOR] --> [James Baker] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_REQUESTEDFORID] --> [8826a6f1-30f9-48d5-9fbf-8369c1153ff5] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_SOURCEBRANCH] --> [$/MathWin] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_SOURCEBRANCHNAME] --> [MathWin] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_SOURCEVERSION] --> [43] [RELEASE_ARTIFACTS_MATHWIN-_NET_DESKTOP-CI_TYPE] --> [Build] [RELEASE_ATTEMPTNUMBER] --> [2] [RELEASE_DEFINITIONENVIRONMENTID] --> [2] [RELEASE_DEFINITIONID] --> [2] [RELEASE_DEFINITIONNAME] --> [New Release Definition] [RELEASE_DEPLOYMENT_REQUESTEDFOR] --> [James Baker] [RELEASE_DEPLOYMENT_REQUESTEDFOREMAIL] --> [jbaker@alliantkeystone.com] [RELEASE_DEPLOYMENT_REQUESTEDFORID] --> [8826a6f1-30f9-48d5-9fbf-8369c1153ff5] [RELEASE_DEPLOYMENT_STARTTIME] --> [2019-10-30 03:10:27Z] [RELEASE_DEPLOYMENTID] --> [10] [RELEASE_DEPLOYPHASEID] --> [10] [RELEASE_ENVIRONMENTID] --> [7] [RELEASE_ENVIRONMENTNAME] --> [Development] [RELEASE_ENVIRONMENTS_DEVELOPMENT_STATUS] --> [InProgress] [RELEASE_ENVIRONMENTURI] --> [vstfs:///ReleaseManagement/Environment/7] [RELEASE_REASON] --> [ContinuousIntegration] [RELEASE_RELEASEDESCRIPTION] --> [Triggered by MathWin-.NET Desktop-CI 20191029.5.] [RELEASE_RELEASEID] --> [7] [RELEASE_RELEASENAME] --> [Release-6] [RELEASE_RELEASEURI] --> [vstfs:///ReleaseManagement/Release/7] [RELEASE_RELEASEWEBURL] --> [https://james-pc/DefaultCollection/f593a1cf-2f36-4f02-ae59-d63a1e7c7691/_release?releaseId=7&_a=release-summary] [RELEASE_REQUESTEDFOR] --> [James Baker] [RELEASE_REQUESTEDFOREMAIL] --> [jbaker@alliantkeystone.com] [RELEASE_REQUESTEDFORID] --> [8826a6f1-30f9-48d5-9fbf-8369c1153ff5] [RELEASE_SKIPARTIFACTSDOWNLOAD] --> [False] [RELEASE_TRIGGERINGARTIFACT_ALIAS] --> [MathWin-.NET Desktop-CI] [REQUESTEDFORID] --> [8826a6f1-30f9-48d5-9fbf-8369c1153ff5] [SYSTEM] --> [release] [SYSTEM_ARTIFACTSDIRECTORY] --> [C:\agent_work\r2\a] [SYSTEM_COLLECTIONID] --> [273478af-6df4-411c-852f-bb4873d309ba] [SYSTEM_CULTURE] --> [en-US] [SYSTEM_DEFAULTWORKINGDIRECTORY] --> [C:\agent_work\r2\a] [SYSTEM_ENABLEACCESSTOKEN] --> [False] [SYSTEM_HOSTTYPE] --> [release] [SYSTEM_JOBID] --> [df0e4399-ea4d-4795-8042-4bfa83bfe923] [SYSTEM_JOBPOSITIONINPHASE] --> [1] [SYSTEM_PARALLELEXECUTIONTYPE] --> [None] [SYSTEM_PLANID] --> [5eeeb4f0-92ac-4aea-8ba8-6b8c238ff3ef] [SYSTEM_TASKDEFINITIONSURI] --> [https://james-pc/DefaultCollection/] [SYSTEM_TEAMFOUNDATIONCOLLECTIONURI] --> [https://james-pc/DefaultCollection/] [SYSTEM_TEAMFOUNDATIONSERVERURI] --> [https://james-pc/DefaultCollection/] [SYSTEM_TEAMPROJECT] --> [MathWin] [SYSTEM_TEAMPROJECTID] --> [f593a1cf-2f36-4f02-ae59-d63a1e7c7691] [SYSTEM_TIMELINEID] --> [5eeeb4f0-92ac-4aea-8ba8-6b8c238ff3ef] [SYSTEM_TOTALJOBSINPHASE] --> [1] [SYSTEM_WORKFOLDER] --> [C:\agent_work] 2019-10-30T03:10:31.7156901Z Download all required tasks. 2019-10-30T03:10:31.7943140Z ##[section]Finishing: Initialize Job 2019-10-30T03:10:31.8802114Z ##[section]Starting: Download Artifacts 2019-10-30T03:10:31.8936111Z Creating artifacts directory: C:\agent_work\r2\a 2019-10-30T03:10:31.9049862Z Created artifacts directory: C:\agent_work\r2\a 2019-10-30T03:10:31.9050009Z Downloading artifact 2019-10-30T03:10:31.9069261Z Starting artifacts download... 2019-10-30T03:10:31.9100169Z Downloading linked artifact MathWin-.NET Desktop-CI of type Build... 2019-10-30T03:10:31.9143397Z Ensuring artifact folder C:\agent_work\r2\a\MathWin-.NET Desktop-CI exists and is clean. 2019-10-30T03:10:31.9243776Z Preparing to get the list of available artifacts from build 2019-10-30T03:10:32.1133650Z Preparing to download artifact: drop 2019-10-30T03:10:32.1283849Z Artifact Type: ServerDrop 2019-10-30T03:10:32.1284265Z Downloading artifact from file container: #/94/drop to target: C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop 2019-10-30T03:10:32.1290490Z Parallel download limit: 4 2019-10-30T03:10:32.1290832Z Download buffer size: 8192 2019-10-30T03:10:32.2992902Z Caching items under 'drop' in the file container... 2019-10-30T03:10:32.3475874Z Caching complete. (48 ms) 2019-10-30T03:10:32.3659269Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathServiceLibrary\bin\Release\MathServiceLibrary.dll.config 2019-10-30T03:10:32.3973864Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathServiceLibrary\bin\Release\MathServiceLibrary.dll 2019-10-30T03:10:32.3983444Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathServiceLibrary\bin\Release\MathServiceLibrary.pdb 2019-10-30T03:10:32.3992486Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathWinService\bin\Release\MathServiceLibrary.dll.config 2019-10-30T03:10:32.4167497Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathWinService\bin\Release\MathServiceLibrary.dll 2019-10-30T03:10:32.4203307Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathWinService\bin\Release\MathServiceLibrary.pdb 2019-10-30T03:10:32.4217191Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathWinService\bin\Release\MathWinService.exe.config 2019-10-30T03:10:32.4275613Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathWinService\bin\Release\MathWinService.exe 2019-10-30T03:10:32.4450798Z Downloading file C:\agent_work\r2\a\MathWin-.NET Desktop-CI\drop\MathWinService\bin\Release\MathWinService.pdb 2019-10-30T03:10:32.4695696Z Download complete. 2019-10-30T03:10:32.4703280Z 9 placed file(s): 9 downloaded, 0 empty 2019-10-30T03:10:32.4704577Z 1 MB downloaded at 635 KB/sec. Download time: 00:00:00.1076238. 2019-10-30T03:10:32.4704947Z Downloaded linked artifact MathWin-.NET Desktop-CI 2019-10-30T03:10:32.4705104Z Finished artifacts download 2019-10-30T03:10:32.4751074Z ##[section]Finishing: Download Artifacts 2019-10-30T03:10:32.4852575Z ##[section]Starting: Deploy Windows Service 2019-10-30T03:10:32.5159288Z ============================================================================== 2019-10-30T03:10:32.5159576Z Task : Windows Service Manager 2019-10-30T03:10:32.5159814Z Description : Deploys a Windows Service to an Agent or a Deployment Group Target using WinRM. 2019-10-30T03:10:32.5159948Z Version : 4.1.23 2019-10-30T03:10:32.5160066Z Author : MDSolutions 2019-10-30T03:10:32.5160194Z Help : More Information 2019-10-30T03:10:32.5160337Z ============================================================================== 2019-10-30T03:10:34.2357053Z Begining deployment to [JAMES-PC] 2019-10-30T03:10:35.4912941Z [JAMES-PC]: Attempting to locate [MathService] 2019-10-30T03:10:36.0282785Z [JAMES-PC]: Identified [MathService] installation directory [] 2019-10-30T03:10:36.0307213Z [JAMES-PC]: Copying [C:\agent_work\r2\a\$(build.artifactstagingdirectory)] to [] 2019-10-30T03:10:36.2586286Z ##[error]Cannot bind argument to parameter 'Path' because it is an empty string. 2019-10-30T03:10:36.2850538Z ##[section]Finishing: Deploy Windows Service 2019-10-30T03:10:36.3056096Z ##[section]Finishing: Release

Dejulia489 commented 4 years ago

This line stands out, it looks as if the variable is not getting expanded...

2019-10-30T03:10:36.0307213Z [JAMES-PC]: Copying C:\agent_work\r2\a$(build.artifactstagingdirectory)] to []

$(build.ArtifactStagingDirectory) is not available. Try using $(AGENT.RELEASEDIRECTORY) instead.

Dejulia489 commented 4 years ago

Here is a link for Azure DevOps variables if you would like to learn more.

jamesebaker63 commented 4 years ago

I changed the ArtifactPath to: $(AGENT.RELEASEDIRECTORY) and the Installation Path to: $(AGENT.RELEASEDIRECTORY) /MathWinService.exe and I am getting the log entries below:

2019-10-30T20:18:22.5307124Z Begining deployment to [JAMES-PC] 2019-10-30T20:18:23.9521370Z [JAMES-PC]: Attempting to locate [MathService] 2019-10-30T20:18:25.0225899Z [JAMES-PC]: Identified [MathService] installation directory [] 2019-10-30T20:18:25.0249153Z [JAMES-PC]: Copying [C:\agent_work\r3\a] to [] 2019-10-30T20:18:25.0250370Z [JAMES-PC]: Starting [MathService] 2019-10-30T20:18:25.3935850Z ##[error]Cannot bind argument to parameter 'Path' because it is an empty string. 2019-10-30T20:18:25.4273438Z ##[section]Finishing: Deploy Windows Service

Any ideas what to do next?

jamesebaker63 commented 4 years ago

What environment variable is the line below reading? 2019-10-30T20:18:25.0225899Z [JAMES-PC]: Identified [MathService] installation directory [] It seems to have an empty value in the [] after directory.

What environment variable is this line reading? 2019-10-30T20:18:25.0249153Z [JAMES-PC]: Copying [C:\agent_work\r3\a] to [] It seems to be empty with the [].

Dejulia489 commented 4 years ago

That’s the install path for the service. Delete the windows service and run the pipeline again.

jamesebaker63 commented 4 years ago

Getting closer:

Log entries: 2019-10-30T21:03:03.7763644Z [JAMES-PC]: Attempting to locate [MathService] 2019-10-30T21:03:03.7766222Z [JAMES-PC]: Unable to locate [MathService] creating a new service 2019-10-30T21:03:03.7768111Z [JAMES-PC]: Identified [MathService] installation directory [C:\agent_work\r3\a ] 2019-10-30T21:03:03.7770657Z [JAMES-PC]: Clean install set to [True], removing the contents of [C:\agent_work\r3\a ] 2019-10-30T21:03:03.7773932Z [JAMES-PC]: Copying [C:\agent_work\r3\a] to [C:\agent_work\r3\a ] 2019-10-30T21:03:03.7776575Z [JAMES-PC]: Starting [MathService] 2019-10-30T21:03:04.0266935Z ##[error][JAMES-PC]: Service responded with [2]. See https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/startservice-method-in-class-win32-service for details. 2019-10-30T21:03:04.0520522Z ##[section]Finishing: Deploy Windows Service 2019-10-30T21:03:04.0790120Z ##[section]Finishing: Release

I want the service to run as Local System do I just put that like "Local System" in the Run As variable?

jamesebaker63 commented 4 years ago

Looking at the service it defaulted it to Local system. I did not provide a Run as UserName or Run As Password. Are they required?

Dejulia489 commented 4 years ago

Don’t install it in the agent folder. It gets removed and cleaned when an agent processes a job. Update the install path to a useful path like c:\my\service.exe. Delete the service and run the pipeline again.

jamesebaker63 commented 4 years ago

Getting a little closer: Logs:

Number 8 error?

2019-10-30T23:18:22.1292611Z Begining deployment to [JAMES-PC] 2019-10-30T23:18:23.3844419Z [JAMES-PC]: Attempting to locate [MathService] 2019-10-30T23:18:24.4537513Z [JAMES-PC]: Unable to locate [MathService] creating a new service 2019-10-30T23:18:24.4540137Z [JAMES-PC]: Identified [MathService] installation directory [C:\Service] 2019-10-30T23:18:24.4542422Z [JAMES-PC]: Clean install set to [True], removing the contents of [C:\Service] 2019-10-30T23:18:24.4545159Z [JAMES-PC]: Copying [C:\agent_work\r4\a] to [C:\Service] 2019-10-30T23:18:24.4547232Z [JAMES-PC]: Starting [MathService] 2019-10-30T23:18:24.7367483Z ##[error][JAMES-PC]: Service responded with [8]. See https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/startservice-method-in-class-win32-service for details. 2019-10-30T23:18:24.7747842Z ##[section]Finishing: Deploy Windows Service 2019-10-30T23:18:24.7953380Z ##[section]Finishing: Release

Dejulia489 commented 4 years ago

Was your install path a path to the service.exe? 8 means the service didn’t start be because of an unknown reason.

jamesebaker63 commented 4 years ago

When I look at the properties on the Services Panel for my service this is what I see:

Path to executable: C:\Service\MathWinService.exe

When I look at the actual directory structure this is the path to the executable that was created from the extension during the installation process where the files are located: C:\Service\MathWin-.NET Desktop-CI\drop\

This is what I have for the Artifact Path: $(AGENT.RELEASEDIRECTORY) This is what I have in the Installation Path: C:\Service\MathWinService.exe

It looks like the extension is installing the service using part of the directory structure from the build process.

This is the first time I have created a build pipeline, so any help is greatly appreciated to get this going.

Thanks!

jamesebaker63 commented 4 years ago

I was able to get it to load into the correct directory structure by changing the Artifact Path to: This is what I have for the Artifact Path: $(AGENT.RELEASEDIRECTORY)\MathWin-.NET Desktop-CI\drop.

Now I am getting Error 14:

[error][JAMES-PC]: Service responded with [14].

I performed a manual install with InstallIutil to verify that the service will installed correctly and it does. Any suggestions on what to do next?

Thanks!

Dejulia489 commented 4 years ago

The service has been disabled from the system. Did you install the service manually and then disable it? Uninstall the service and let the pipeline install it.

jamesebaker63 commented 4 years ago

I was able to get my service to Build and Release.

Thanks for your support!

Dejulia489 commented 4 years ago

Woo!

I am sure the next one will be much easier, it has a bit of a learning curve. If you can think of anything to add to the documentation that might help I would be happy to add it, or accept a pull request.