Powershell ISE F5 behavior for script module (.PSM1 file) - powershell-ise

When I'm editing a PowerShell script module (.psm1) in the ISE, and I press F5, nothing happens. It doesn't even save the script module to disk, like it does if I'm editing a script (.ps1) file.
What I'd expect to have happen is for it to save the file (if dirty) and then execute a Import-Module -Force command for the module, and perhaps running some tests I've got defined for it.
I know there the ISE is extensible, is there a way to enhance the ISE to get this behavior for F5?

"PowerShell modules enable you to partition, organize, and abstract your Windows PowerShell code into self-contained, reusable units." - Writing a Windows PowerShell Module
In order for you to run the code in your module, you need to import it through a regular PowerShell script, see Windows PowerShell Module Concepts for more information

Related

PowerShell Script Runs correctly in ISE however, it fails through SCORCH Runbook Run .Net Script Activity

I am able to run Powershell script in ISE however, same script does not Run through "Run .Net Script" Activity in Orchestrator Runbook. It fails on minor errors where error action Silently continue is defined.
It is not specific to any single script. But, for all.
SCORCH Version 2019

launch a .bat in TFS2015 build

I have a problem trying to launch a server via a .bat file during a TFS build.
I usually launch the server via a cmd window and it works fine.
When I set it in the TFS build, I end up with the following message :
"'..\server_common.bat' is not recognized as an internal command or external, an executable or a command file".
I also have the following line:
"java -Dsun.lang.ClassLoader.allowArraySyntax=true -Xbootclasspath/a:..\..\..\lib\framework\serverjvm15.jar; -cp ..\..\..\lib\framework\fwtime.jar;" indicating a java syntax error (? I'm not skilled in java)
This batch calls other .bat files and sets java VM-related environment variables
From my research, it is probably a problem of rights as I don't have admin rights when I use TFS. However, all the other steps in the build work fine (installing and launching an appli through command lines, or launching a python script via command lines).
However I also tried to launch a basic script with the same kind of step and it works.
First, suggest you to follow the tutorial in Batch script. Make sure you have meet the requirements of Arguments and used correctly. Such as
Path
Specify the path to the .bat or .cmd script you want to run. The path
must be a fully qualified path or a valid path relative to
the default working directory. In Team Foundation Build, this
directory is $(Build.SourcesDirectory).
Also RDP to your build agent and use your build service account manually run the server_common.bat to narrow down if the account have enough permission.

Missing SEAM_HOME environment variable fails Ant build

My machine just had its hard drive re-imaged so I'm trying to rebuild it. At this point, I am trying to execute an ant script which has worked for years. Not anymore. When the script compiles the javac errors because it can't find a directory.
The error is...
BUILD FAILED
C:\Users\WHeckle\Documents\temp\6.9.2\build-tceq.xml:92: C:\Users\WHeckle\Documents\temp\6.9.2\${env.SEAM_HOME}\lib does not exist.
It looks like it is concatenating the current directory with seam_home and using it as a library reference to the compiler.
I am at a loss to explain the behavior. Any help is appreciated.
The Ant script expects to find a Windows environment variable named SEAM_HOME.
To get the script to work...
Close any Command Prompts that are open.
Create a SEAM_HOME Windows system environment variable (if this step is unclear, search Google to find instructions on how to do this for your version of Windows).
Open a new Command Prompt.
Run echo %SEAM_HOME% in the Command Prompt to confirm that the environment variable is set.
Re-run your Ant script.
SEAM_HOME appears to be related to JBoss. For an example of what the value of SEAM_HOME can be, see this JBossDeveloper forum post.

Run Powershell script that lives in TFS source control

I'm trying to run a Powershell script during my build process, but I can't figure out how to access the ps1 file which is checked into source control (TFS 2010). There is a similar SO question that exists, but I'm actually not sure if it's correct:
TFS 2010: run powershell script stored in source control
My TFS source control is setup as such:
=Project
==BuildScripts
===MyScript.ps1
==Code
===Dir1
====MySolution.sln
I thought passing something like SourcesDirectory + "\..\..\MyScript.ps1" (to tell Powershell where the script is) would work, but I think I'm off somewhere.
Can someone help me figure out how to reference the ps1 file, and run it?
You will need to have a Workspace setup in your Build Definition that includes the directory with the Powershell script.
So your mapping might be like:
*Server* *Workspace*
$/Project/Code/Dir - $(SourcesDir)
You will need to add:
*Server* *Workspace*
$/Project/Code/Dir - $(SourcesDir)
$/Project/BuildScripts - $(SourcesDir)/BuildScripts
Your InvokeProcess can then pass Path.Combine(SourceDirectory, "BuildScripts", "MyScript.ps1") to the Powershell command line.
N.B. You could also set the $/Project/Code/Dir workspace to $(SourcesDir)/Code.

How can I run custom tools from a premake build script?

I'm using protocol buffers for data serialization in my C++ application. I would like to add the invokation of the protoc code generator in my premake build script (thus ensure the up-to-date state of the generated classes and avoid the need to store generated source under version control).
Even their FAQ has a question and answer about this, but the answer is very incomplete for me. Having the ability to call any lua function is great, but where exactly do I put that call? I need to run the protoc compiler before building either the application or the unit tests.
You can certainly call outside code from Premake scripts. But remember: Premake scripts are used to generate build files: Makefiles, C++ projects, etc. The Premake script is run before building the project.
If you want this preprocess to be run outside of the actual build files (and not by make, VC++, Code::Blocks, etc), then it's easy. Lua's os.execute will execute a command-line.
Premake scripts are still Lua scripts. All of the Premake commands are just Lua calls into functions that Premake defines. Premake executes the scripts, then uses the data from them to generate the build files. So all of your Lua code is run during the execution of the script. Where you put this command in your script is irrelevant; wherever it is, it will execute before your build files are generated.
And if you want to run the protoc step during the build (from VC++, makefile, etc.) you can set up a prebuild command. See http://industriousone.com/prebuildcommands for more info and an example.

Resources