问题
still, I am fiddling around within the MSBuild-/MSDeploy-world and have been scratching my head far too often lately.
I want to be able to build a Web Application Project only once and deploy it to multiple configurations. I found this PackageWeb-Solution from Sayed I. Hashimi which enables you to add a Nuget-Package to your WAP that will add additional files to a generated WebDeploy-Package. (You can actually take a look at this 5-Minute-Video to get the basics of what this post is about.) Those files enable me to choose the configuration I desire while (well actually just before ;-)) publishing; that way I can choose in my publishing process which web.config-Transform I want and a "special" (powershell-)script that gets shipped with that Nuget-Package does the magic and publishes the project with exactly that transform.
So my actual problem now is with the execution of this script. So if you are in fact familiar with PackageWeb you may not need to read the full story that follows, but jump to part 3 where the trouble really begins.
1. First Try: Deploying locally
When I try it out locally, it works. The parameters I pass for this are
- the Transform I want to publish
- IIS Web Application Name
- Computer name
- Username
- Password
- Allow untrusted certificate
- whatif
So I choose my desired Transformation and set
- IIS Web Application Name: DeployApp/DeployThis (DeployApp is the Site in my IIS and DeployThis is the actual application running on this site)
- Computer name: localhost
- Username: someName
- Password: guesswhat
- Allow untrusted certificate: true
- whatif: false
And at the end of the script I see this results in the following command:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-verb:sync
-source:archiveDir="C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip"
-dest:auto,includeAcls='False',Username=someName,Password=guesswhat,AuthType='NTLM'
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-setParamFile:"C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip\SetParameters.xml"
-skip:objectName=dirPath,absolutePath="_Deploy_"
-skip:objectName=filePath,absolutePath=web\..*\.config
-skip:objectName=dirPath,absolutePath=_Package
-skip:objectName=filePath,absolutePath=.*\.wpp\.targets$ -allowUntrusted
And it deploys! No errors, no warnings, just pure local deployment pleasure :).
2. Second Try: Deploying remotely
Now, the hard part: I am trying to deploy to a remote machine that I have set up in VirtualBox.
So, in theory I should be able to perform the same action on a remote computer if I just apply the needed adaptations to
- IIS Web Application Name
- Computer name
- Username
- Password to make it fit the destination enviroment. (Given, of course, account permissions and service installations are correct on that remote machine)
So I changed those 4 values to
- IIS Web Application Name: DeployApp/DeployThis (IIS structure is set up the same way as my local computer in this case)
- Computer name:
172.16.200.13
- Username: someOtherName
- Password: haveAnotherGuess
And at the end of the script I see that this results in this slightly different command:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-verb:sync -source:archiveDir="C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip"
-dest:auto,includeAcls='False',ComputerName='172.16.200.13?site=DeployApp/DeployThis',Username=someOtherName,Password=haveAnotherGuess,AuthType='BASIC'
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-setParamFile:"C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip\SetParameters.xml"
-skip:objectName=dirPath,absolutePath="_Deploy_"
-skip:objectName=filePath,absolutePath=web\..*\.config
-skip:objectName=dirPath,absolutePath=_Package
-skip:objectName=filePath,absolutePath=.*\.wpp\.targets$
-allowUntrusted
And quits with the message:
Could not connect to the remote computer ("Some.IP.-.Address")
On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.)
This is what led me to believe that I got some sort of a configuration problem with my virtual machine and post this question.
3. Third Try - Yet another error message, HURRAY it is not the same error
So I dug a bit and found out, that for remote deployment just setting the computer name to the IP-Address of your target in that script is not enough I had to provide the address of the destination service doing the job, so I changed my settings for the computer name from try 2 to
- Computer name:
https://172.16.200.13:8172/msdeploy.axd
This time the generated command looks like this:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-verb:sync
-source:archiveDir="C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip"
-dest:auto,includeAcls='False',ComputerName='https://172.16.200.13:8172/msdeploy.axd?site=DeployApp/DeployThis',Username=someOtherName,Password=haveAnotherGuess,AuthType='BASIC'
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-setParamFile:"C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip\SetParameters.xml"
-skip:objectName=dirPath,absolutePath="_Deploy_"
-skip:objectName=filePath,absolutePath=web\..*\.config
-skip:objectName=dirPath,absolutePath=_Package
-skip:objectName=filePath,absolutePath=.*\.wpp\.targets$
-allowUntrusted
BUT I got another error, which made me partially happy, because I was looking at that error I mentioned before for hours and was doubting myself and the service's configuration on my virtual machine but could not find anything:
Web deployment task failed.
(Could not connect to the remote computer ("Some.IP.-.Address") using the specified process ("Web Deployment Agent Service") because the server did not respond.
Make sure that the process ("Web Deployment Agent Service") is started on the remote computer.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC.)
4. Fourth Try - Fiddling with the generated command
So after a little more digging I felt lucky enough to try some manual adjustments to that generated msdeploy-command. I found out in some posts on SO that for the ComputerName-parameter of msdeploy in this case, the actual application should not be mentioned, instead only the site name should be given (I guess the application name then will be grabbed somehow from the package's parameters? Maybe someone can clear that up for me, too)
So I ended up trying out this slightly modified command:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-verb:sync
-source:archiveDir="C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip"
-dest:auto,includeAcls='False',ComputerName='https://172.16.200.13:8172/msdeploy.axd?site=DeployApp',Username=someOtherName,Password=haveAnotherGuess,AuthType='BASIC'
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-setParamFile:"C:\Users\someName\AppData\Local\Temp\DeployDBVariantion00_zip\SetParameters.xml"
-skip:objectName=dirPath,absolutePath="_Deploy_"
-skip:objectName=filePath,absolutePath=web\..*\.config
-skip:objectName=dirPath,absolutePath=_Package
-skip:objectName=filePath,absolutePath=.*\.wpp\.targets$
-allowUntrusted
And now that actually did the deployment!
5. Aftermaths - Hurray and Meeeeh! at the same time?
So this is the point where I find myself right now; I got a command which works, but no clue how I can get that script to generate that one for me. Well actually I could make some guesses about how I can adjust that script to meet my requirements, but do not think that they're that special, besides the script gets generated each time a WebDeploy-Package is being generated so only altering the generated script won't get me much benefit. Just so you can see that try, too, in that script "Publish-Interactive.ps1" in line 371 it says
$compNameCommandFrag = ",ComputerName='{0}?site={1}'" -f $compNameFixedUp, $siteNameParam.Value
I can "hack" this to work for me in just this use case to generate the msdeploy command, that I want if I change it to
$compNameCommandFrag = ",ComputerName='{0}?site=DeployApp'" -f $compNameFixedUp#, $siteNameParam.Value
But we all probably agree, that this is dirty and obviously not what I want to do if I install that Nuget-Package/script into multiple projects.
This confuses me a lot, because I am constantly under the impression that I am using the script the wrong way. The other possibility would be that the script itself is flawed or simply not fit for my purpose. I am posting this here, because I refuse to believe that the script itself is flawed and I really don't think my use case is that special.
So to sum it up:
I am looking for an answer to what needs to be done to correctly set up the parameters the powershell script prompts for to achieve what I described above (still assuming this is a configuration problem on my side, not an error in the Nuget-Package itself).
Hope someone understands my problem and can help. Thanks in advance to anyone who works through this post ;)
回答1:
Well, as it turned this is indeed a problem this script is having with remotely deploying into a "nested" site-application-structure.
Posted issue on the project's site
来源:https://stackoverflow.com/questions/16837558/what-parameters-do-i-need-to-pass-to-the-packageweb-powershell-script-to-make-it