I set up TFS Deployer currenlty at work and have been tried to write a Powershell script for the deployment. I have been researched and read many posted questions and answers at StackoverFlow but I couldn't really making the script working yet.
So far, when I run the following PS on windows PowerShell ISE, it runs.
$envMsDeploy = $env:msdeploy
$DirMsDeploy = split-Path -Parent $envMsDeploy
# defined the current location to $DirMSDeploy = C:\Program Files\IIS\Microsoft Web Deploy V2
set-location $DirMsDeploy
$arg = #(
'-verb:sync';
'-source:contentPath=' + $buildDroppedLocation;
'-dest:contentPath=' + $destinationPath;
' -whatif > c:\temp\msdeploy.log'
)
$runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg)
$runMSDeploy | Out-file c:\temp\MsDeployTest.bat
I put the last sentence to confirm what gets saved $runMSDeploy. Now looks like $runMSDeploy saves what I want to put finally.
MSDeployTest.Bat contains C:\Program Files\IIS\Microsoft Web Deploy V2\Msdeploy.exe -verb:sync -source:contentPath=[[c:\source folder]] -dest:contentPath=[[Detination UNC path]] -whatif > c:\temp\msdeploy.log
This is where I'm stuck at right now. Because of the c:\Program files contains the empty folder, cmd doesn't run successfully rather giving me the error, "cmd.exe : 'C:\Program' is not recognized as an internal or external command"
If you have any suggestions or idea, please let me know.
thanks,
wanttogoshreddingeveryday
Here is a small example which start notepad.exe with a parametter
function F([string]$file)
{
notepad.exe $file
}
Clear-Host
F "c:\Temp\fic.txt"
JP
Try this gist. It should have everything you need to deploy via powershell https://gist.github.com/579086
It uses Psake, but it will work without it as well.
Related
I'm trying to publish a dotnet core app to Azure. I've created a publish profile and using visual studio it all works fine. But since I'd like to setup continuous deployment I need to run the deployment using command line.
The official documentation was pretty helpful in identifying that the [ProfileName].ps1 is the best plan of attack.
However it gives no clues on how to use it.
First I ran it without parameters and got this error:
Production-publish.ps1 : The term 'Production-publish.ps1' 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.
At line:1 char:1
+ Production-publish.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Production-publish.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Next I added the needed parameters:
.\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml'
Which ran without error but didn't do ANYTHING!
How can I make the Azure depoyment via Powershell work?
After debugging through the publish-module.psm1 to figure out why nothing was getting deployed I noticed that the command is required to supply more parameters. This is how:
.\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml' -publishProperties #{
'username' = '%PublishProfile.Username%'
'Password' = '%PublishProfile.Password%'
'AllowUntrustedCertificate' = false
'AuthType' = 'Basic'}
You obviously have to replace %PublishProfile.Username% and %PublishProfile.Password% and possibly modify Production-publish and Production.pubxml
Note that only the Password parameter is required (considering that the UserName is provided in your .pubxml file)
I actually ended up writing blog article on how to compile and deploy asp.net core sites with TeamCity:
How to deploy ASP.NET Core sites using Teamcity to Azure/IIS … or just command line
Trying to run the opentripplanner and using the Graph.obj to run it for a country.
But whenever trying to run the server it is giving the filenotfound exception at location /otp/Graph.obj although i have put the Graph.obj in the same location.
Stacktrace while running the server is :
Graph file not found or not openable for routerId '' under file:/otp
java.io.FileNotFoundException: /otp/Graph.obj (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:146)
at java.io.FileInputStream.(FileInputStream.java:101)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
I had the same problem trying to run OTP.
First problem: the routerId is missing
Second problem: the default directory is /var/otp/graph and OTP seems to search the graph under /var/otp/graph/{routerId}
Third problem (may not be yours): I tried to run OTP in Cygwin (Windows) and probably there was some trouble with the slashes/backslashes, so I decided to copy the graph under a "../gtfs/gurgaon"
Solution:
Step 1) create a subdirectory like "/var/otp/graph/gurgaon" and copied Graph.obj over there
Step 2) run something like: $ java -jar target/otp.jar --router gurgaon --graphs ../gtfs --server
It worked like a charm for me!
Try this code: java -Xmx5G -jar target/otp-0.20.0-SNAPSHOT-shaded.jar --build path your gtfs and osm.pbf files --inMemory
It worked perfect for me.
I need some Powershell advice.
I need to install an application's MSP update file on multiple Win08r2 servers. If I run these commands locally, within the target machine's PS window, it does exactly what I want it to:
$command = 'msiexec.exe /p "c:\test\My Application Update 01.msp" REBOOTPROMPT=S /qb!'
invoke-wmimethod -path win32_process -name create -argumentlist $command
The file being executed is located on the target machine
If I remotely connect to the machine, and execute the two commands, it opens two x64 msiexec.exe process, and one msiexec.exe *32 process, and just sits there.
If I restart the server, it doesn't show that the update was installed, so I don't think it's a timing thing.
I've tried creating and remotely executing a PS1 file with the two lines, but that seems to do the same thing.
If anyone has advice on getting my MSP update installed remotely, I'd be all ears.
I think I've included all the information I have, but if something is missing, please ask questions, and I'll fill in any blanks.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
My process for this is:
Read a CSV for server name and Administrator password
Create a credential with the password
Create a new session using the machine name and credential
Create a temporary folder to hold my update MSP file
Call a PS1 file that downloads the update file to the target server
>>> Creates a new System.Net.WebClient object
>>> Uses that web client object to download from the source to the location on the target server
Call another PS1 file that applies the patch that was just downloaded –>> This is where I’m having issues.
>>> Set the variable shown above
>>> Execute the file specified in the variable
Close the session to the target server
Move to the next server in the CSV…
If I open a PS window and manually set the variable, then execute it (as shown above in the two lines of code), it works fine. If I create a PS1 file on the target server, containing the same two lines of code, then right click > ‘Run With PowerShell’ it works as expected / desired. If I remotely execute my code in PowerGUI, it returns a block of text that looks like this, then just sits there. RDP’d into the server, the installer never launches. My understanding of the “Return Value” value is that “0″ means the command was successful.
PSComputerName : xx.xx.xx.xx
RunspaceId : bf6f4a39-2338-4996-b75b-bjf5ef01ecaa
PSShowComputerName : True
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId : 4808
ReturnValue : 0
I even added a line of code between the variable and the execution that creates a text file on the desktop, just to verify I was getting into my ‘executeFile’ file, and that text file does get created. It seems that it’s just not remotely executing my MSP.
Thank you in advance for your assistance!
Catt11.
Here's the strategy I used to embed an msp into a powershell script. It works perfectly for me.
$file = "z:\software\AcrobatUpdate.msp"
$silentArgs = "/passive"
$additionalInstallArgs = ""
Write-Debug "Running msiexec.exe /update $file $silentArgs"
$msiArgs = "/update `"$file`""
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs"
Start-Process -FilePath msiexec -ArgumentList $msiArgs -Wait
You probably don't need to use the variables if you don't want to, you could hardcode the values. I have this set up as a function to which I pass those arguments, but if this is more of a one-shot deal, it might be easier to hard-code the values.
Hope that helps!
using Start-Process for MSP package is not a good practice because some update package lockdown powershell libs and so you must use WMI call
i am a toddler on Twisted .I am trying to run a Twisted web server using the command
twistd web --resource-script=~/Desktop/step/ecdemo.rpy
assume that my file(ecdemo.rpy) is located on desktop in step folder
the traceback when i visit the page(127.0.0.1:8080/ecdemo.rpy) shows
<type 'exceptions.IOError'>: [Errno 2] No such file or directory: '~/Desktop/step/ecdemo.rpy
however if i run the same file with command
python ecdemo.rpy it runs smoothly.
The program simply renders a get request from an http page
I know it is something basic that i do not know but if you could help me get started i would come up with better problems...
thanks for help.
Your shell didn't expand ~ into your home directory. Try this instead:
twistd web --resource-script ~/Desktop/step/ecdemo.rpy
Notice I removed the = between the option name and its value. This will probably let your shell turn ~ into /home/whoever.
I am asked to build a qt based solution file using msbuild.I tried with a below command and i am ending up in getting a error.I could able to build a wix project with same command shown below.
C:\Windows\Microsoft.NET\Framework\v4.0.30319>MSBuild "C:\path\to\my solution file\my.sln" /t:Build /p:Configuration=Release /p:Platform=Win32
With these, i am getting a error saying,
C:\Program Files\MSBuild\Microsoft.CppCommon.targets(155,5):
error MSB6006: "cmd.exe" exited with code 3. [c:\my\path to\project file\my.vcxproj]
The paths of various files in my.vcxproj are not read by the system when Moc'ing.I get the below error
InitializeBuildStatus:
Touching "Win32\Release\my.unsuccessfulbuild".
CustomBuild:
Moc'ing "dialog.h"...
The system cannot find the file path specified
Moc'ing "Centralwidget.h"...
The system cannot find the file path specified
and so on....
I have tried to build using qmake too,but not succeeded.Looking forward for the good suggestion for which method to use to build a qt based solution file.Thanks in advance
Build a Qt solution file using MSBuild,
def buildsolution(self,solutionpath):
if not os.path.isfile(self.msbuild):
raise Exception('MSBuild.exe not found. path=' + self.msbuild)
arg1 = '/t:Rebuild'
arg2 = '/p:Configuration=Release'
arg3 = '/p:Platform=Win32'
proc = subprocess.Popen(([self.msbuild,solutionpath,arg1,arg2,arg3]), shell=True,
stdout=subprocess.PIPE)
while True:
line = proc.stdout.readline()
wx.Yield()
if not line: break
proc.wait()
Where self.msbuild=r'C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe' and
solutionpath=r'path to\qt solution file\my.sln'