Reputation: 301
I have a PowerShell script set to execute after an MSBuild is finished. It uses environment variables set in the POSTBUILD section of the build process (build directories and the like.) Currently it looks like this:
set MAGE="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe"
set APPFILE=$(TargetDir)$(TargetName).application
set MANIFEST=$(TargetPath).manifest
set CERT=$(ProjectDir)$(TargetName).pfx
set PROJECTNAME=$(TargetName)
set CONFIGURATION=$(ConfigurationName)
set TARGETDIR=$(TargetDir)
set TEAMBUILD=$False
Powershell -File "$(ProjectDir)POSTBUILD.ps1"
With each set operating on a separate line, but still within the same CMD instance.
Is there a way I can set multiple variables at once using just one line instead of 7?
Upvotes: 11
Views: 22381
Reputation: 4065
As Ansgar points out, a better solution would be to daisy-chain the commands as follows:
set "A=foo" & set "B=bar" & set "C=baz"
You could even inline the script execution also:
set "A=foo" & set "B=bar" & set "C=baz" & Powershell -File "$(ProjectDir)POSTBUILD.ps1"
Upvotes: 15
Reputation: 1535
Yes, you can pipe the commands together:
set A="hi" | set B="bye"
Upvotes: 13