Reputation: 415
I have a Powershell script that reads the Assembly version from a dll, I want to store this return value in a variable, I am running the ps1 script from a post-build event:
When i execute the script:
powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath)
The post build event produces this:
1>1.0.8146.38525
I want to assign this value to a variable to be able to use it later in another operation, unfortunately, it has not worked
A=(powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath))
I have also tried this:
A=$(powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath))
None of these two solutions is working.
My Powershell script is the following one:
$strPath = $args[0]
$Assembly = [Reflection.Assembly]::Loadfile($strPath)
$AssemblyName = $Assembly.GetName()
$Assemblyversion = $AssemblyName.version
$Assemblyversion.ToString()
I appreciate your comments and suggestions
Upvotes: 0
Views: 107