Windows task scehduler not fully completing a task - scheduled-tasks

I have some Nunit automated tests. I am trying to use Nunit console to run those tests over Selenium grid. I have created a .bat file to launch the tests over the grid, which looks at a list of tests in a text file.
When I manually run the .bat file, my tests run and I get an xml results file automatically created.
When I get windows task scheduler to run the .bat file, my tests will run, however, I do NOT get my test results.
Need help understanding why I do not get my results if I use task scheduler.
Here is the .bat file contents;
nunit-console /result:console-testResults2.xml /work:C:\Selenium\TestResults /runlist:C:\Selenium\testlist.txt "C:\Selenium\VisualStudio\Automated Tests\Automated Tests\AutomatedTests\bin\Debug\AutomatedTests.dll"

I had the same problem, turns out it was because of where it runs the tests from. Once I set the "Start In" option to the same directory as my test dll, then it created the XML file in that directory fine.

Related

Powershell script to download either zip or csv

I use ssis to run a powershell script to download a file that used to be csv but recently became large enough to be zipped. I updated the powershell script to look for a zip file and added a task to the package to unzip the file so it can be loaded into a sql database. Well, then it came through as a csv again. I need a solution to choose either the zip file or the csv file. Not sure if this should be a task in ssis or updated powershell.
I would go with a PS task to download the files (either zip/csv) then SSIS foreach container to iterate over the files you just downloaded. Doing this you will assign the individual file to a user variable. Inside your container if the file is zip, (use a variable set via an expression to determine if it is zip or not) run a task that will run PS to unzip and then a expression task to update the variable that holds the file path to be the newly unzipped csv path. Then run your data flow task to import the csv.
If the file is a csv to begin with, then just run the DFT.
Either way the data flow task is the same, take csv and load it. I have found I like to keep my PS in SSIS packages very purpose driven. I have a tendency to build my logic in PS because it is easier, but then my package becomes harder to debug because an issue in my PS script will fail the SSIS package and SSIS tells me nothing usefull about what in the script failed. (unless you are handling redirecting of stdout and stderr from your PS, or doing some other logging)
Best to keep the powershell as simple as needed for each task you need to do.

run a powershell script as a task in VSTS

I need to run a powershell script as a task when doing the release in VSTS. The script runs perfectly if I run it form the powershell IDE, but I can't configure the script to run as a task in the parameter script path. I'm using $(System.DefaultWorkingDirectory)/vs-releasenotes.ps1 but it does not work
The script is top level in the folder solution. How can I access the ps1 scritp if it is localted at solution level (no folder for the script)
Thanks
Found the error, I was running the script during the release phase but did not add the ps1 file to the task that copied all the files to the build directory, so it was not available. I just added the file and everything works ok

Is it possible to run a batch file from package manager console?

I'm using code first migrations with my context class in a class library (ie not the startup project) and I want to make batch files for the common operations to save having to pass in the parameters each time I want to add-migration and update-database. I ran the "dir" command in the console and it appears to be in the solution root folder so I have tried creating a .bat,.cmd or .ps1 file in the Solution Items folder but the package manager powershell doesn't seem to be able to find it?
At this very moment I am happening to read this from Bruce Payette's "Powershell in Action" (Wonderful book) so share something with you, lucky guy:
"In this example (Poster: an example in the book), even though hello.ps1 is in the current directory, you had to put ./ in front of it to run it. This is because Powershell doesn't execute commands out of the current directory by default. This prevents accidental execution of the wrong command."
Looks like I needed to just put a ".\" on the beginning of the batch file name - not sure if Powershell requires this to execute?

Error when attempting to deploy a WAR to Glassfish 3 using an Ant Build Script

I am investigating how to use both Glassfish and Ant buildfiles. I've written a build script (for the first time) which will create a WAR file of my basic Hello World app.
I am then trying to deploy this WAR to Glassfish as part of the build script. I found details of the glassfish-deploy task and have managed to get this included in the build script after including the ant-task jar file in the class path.
However, when I run the script I get the message:
[glassfish-deploy] Install Directory of application server not known. Specify either the installDir attribute or the asinstall.dir property
I've tried to find out what is meant by this, but can find no reference to either the installDir attribute or the asinstall.dir property. I have managed to deploy the created WAR file through Glassfish's admin webpage but I cannot seem to get this Ant script to do it successfully.
Any pointers or guidance would be most helpful.
OKay after a lightbulb moment I managed to resolve this by editing the task in my build script so it is now <glassfish-deploy file="${name}.war" installDir="C:\\glassfish3\\glassfish" force="true"/>
As it appears that the ant script does not know where Glassfish is installed. This resolves the issue and the script runs (and workds) However the next stage is to figure out how to do this without having to hardcode the location into into the build script. Especially if I want to write a script that can deploy the WAR file to a remote server.

Running script only for an 'Archive' build in Xcode 4

I have a script that I run using osascript from a Run Script Build Phase in Xcode 4. This script does some checks to try and catch any human-error in plists and suchlike.
However, I only really want to run this script when a developer chooses 'Archive' as opposed to running it every time they build.
Is there any way of testing for this situation? Either in Shell Script or Apple Script?
In Xcode 4+, you could run this script as a pre- or post-action script on the "Archive" action. However, pre- and post-action scripts are not considered part of the build itself; their output is not part of the build log, and a failing script will not cause the build to fail.
If you want to include this script as a first-class part of the build, such that its failure will cause the build to fail, then you'll want to do something else. Make a new "External Build System" target, and configure it to run your script. The path to your script can be a relative path, relative to the project root.
Finally, open your main project scheme, and in the "Build" tag add the new checker target, and set it to only be included in the "Archive" action. This should cause your checker script to be run as part of the build only when "Archive" is selected, and if the script returns a non-zero value the build will fail.
Here's a step-by-step visual guide to configure a bash script to run only when archiving a target:
File > New > Target > Other > External Build System
Name the product accordingly and set /bin/bash as the Build tool
Provide the path to the script under Info > Arguments of the newly created target
Product > Scheme > Edit Schemeā€¦, and edit the scheme of the target where you want this script to run before archiving. Under Build, add the External Build System target you added in step 1. Reorder if needed. Then uncheck everything except Archive.
Add a "New Run Script Phase" to your project's "Build Phases"
Move (drag&drop) your script in the right position
Check the "Run script only when installing"
If you don't do 3. the script will run all the time, but if you check that box, it will only run when archiving.
So in latest Xcode (13.3) you can edit your schemes and copy & paste (or drag&drop) your executable script in the run script textfield (see image).
The pre-Action is executed before the Organizer is opened and the post-action is executed after the build landed in the archives list of products. In both cases the build process of archiving will run through beforehand.
A quick test on my own system shows no difference in the detailed script output between straight "Build" and "Build and Archive".
Also, you can't test for the presence (or absence) of the archive, since it only gets created at the very end of the process, when all scripts have been run.
As far as I can see, there is no current option within Xcode 3 to do this. Maybe file an enhancement request with Apple?
While you wait on Apple, the only solution I can offer is to use xcodebuild and xcrun as part of a command-line shell script, where you would know if you are archiving or not. This is not a stay-in-Xcode solution, but it does have a lot of flexibility.
Xcode "Build and Archive" from command line