Visual Studio Post-Rebuild / Post-NoBuild Event? - visual-studio

I'm working on a project where I need a script to execute when someone hits "F5" or "F6", even if the code in the project hasn't changed.
The script is responsible for copying data from a different directory - data that may have changed.
I've noticed that this works properly as a post-build event, but only if the project is actually rebuilt. How do I get the event to trigger without requiring a clean each time?

These are the steps I followed to setup the script to run when I needed it:
Opened Project > Properties
Navigate to Custom Build Step > General
Put the script command in the "Command Line" field
Set an arbitrary output filename (this is required, if you don't have an output filename, visual studio will skip your custom build step) I chose an arbitrary filename ".filename" if I were to get fancy I'd also have the script output a log to this file
Set the "Execute After" field to "FinalizeBuildStatus" This ensures that the command will execute after the build status has been established (which happens in all circumstances when you'd hit F5 or F6, even if you haven't changed any code in the project).
I was surprised not to find these steps clearly outlined elsewhere online. Perhaps I'm bad at googling, but since I solved my own problem I find it only fitting to share in case someone else has this problem.

Related

TFS API DownloadFile( ) functions cause exception when debugging

Whenever I call Item.DownloadFile(string localFileName) or VersionControlServer.DownloadFile(string serverPath, string localFileName) I get a FileNotFoundException whenever I try to debug in Visual Studio: Could not find file 'C:[Project Path]\bin\Debug\[ProjectName].vshost.exe.config'.
When I build the application and run it outside of visual studio there is no problem calling these functions. It works perfectly fine. Anyone know what could be causing it?
Before you ask, no, that file does not exist. I'm not doing anything with a config file, I don't need or want it to exist. I don't understand why it is even trying to access that file when I debug. When I run the application outside of visual studio that .config file still does not exist but I get no exception because it's not trying to access that file.
Also, it is not a vshost problem either. When I uncheck "Enable the Visual Studio hosting process" I get the same exception except when debugging but the file name changes from "[ProjectName].vshost.exe.config" to "[ProjectName].config"
Currently, when I want to debug this project I have to put a MessageBox.Show( ) function right after every call to DownloadFile( ) and run my application outside of visual studio. When that MessageBox is displayed then I can use attach to process and put a break point on the next line after that MessageBox, click OK on the messagebox and then it will catch the break point. But when I'm downloading files in a loop and want to debug the loop it's extremely annoying and time consuming to attach to process after DownloadFile is called, stop debugging before the next DownloadFile is called, attach to process again after DownloadFile is called, and keep repeating that all day long.
I'm not totally sure, but looks like it has something to do with the current path and the Workspace where you download the file to.
If you don't explicitly specify the workspace, the TFS API will try to determine it from the current path of your application by looking if that path is declared in a Workspace as a Mapping.
If I remember correctly, you can download an item from a Workspace object (or specify the Workspace in the operation), try to modify your code to do that and see if it's better.
You can also try to change the current path of your debugging session to something "inside a Workspace"

Debugging UDK using nFringe in Visual Studio 2005

This is a pretty niche question, so I am not expecting a huge response...
Basically, I am learning how to use the UDK by following some tutorials, namely this one:
http://forums.epicgames.com/showthread.php?p=27043379#post27043379
So far everything is going pretty well. The only real hangup I've had is getting everything to work in Visual Studio 2005 using this nFringe plugin. For a long time, couldn't get them to work at all. I've gotten into two or three chapters of the tutorial, and I've managed to use Visual Studio to edit the code, but I can't build the scripts within VS; I have to go to UDK Frontend to do that. And worse still, I can only really use Log commands in the unrealscripts to debug anything.
So my question is this: is it even possible to configure these tools in a way that I can put breakpoints in VS and have them be caught when I test the game? I feel as though I don't have something setup correctly.
Yes it is possible. Here are some info which might be useful to you.
First, both your .sln and your .ucproj files must be located in Development/src. Then, under visual studio, right-click your project (.ucproj file in the solution explorer) and open its properties.
You must set, under the General tab:
Target Game: UnrealEngine 3 Mod
UCC Path: ....\Binaries\Win32\UDK.exe
Reference Source Path: ..\Src
Under the Build tab:
check "Build debug scripts"
Under the Debug tab:
Start Game Executable: ....\Binaries\Win32\UDK.exe
Load map at startup: the name of your startup map, without path nor extension
Start with the specified game type: put your GameInfo class used for your mod, ie. MyMod.MyGameInfo
Disable startup movies can be checked to gain time at launch
Enable unpublished mods must be checked.
In your command line, the parameter -vadebug specifies that the breakpoints will be enabled.
After that, you must be able to build your script from Visual, and launch your game by pressing F5.
Breakpoints should work but you can't put them on a variable declaration, you have to put them on a function call, an assignment or a condition statement.
Hope this will help.
I havnt tried using breakpoints yet but I know its possable to build with nfringe and visual studio . You need to add a line to the
udk game / config / udk engine .ini
search for
editpackages
exactly like that , then youll see a block like this
EditPackagesInPath=....\Development\Src
EditPackages=Core
EditPackages=Engine
EditPackages=GFxUI
EditPackages=GameFramework
EditPackages=UnrealEd
EditPackages=GFxUIEditor
EditPackages=IpDrv
EditPackages=OnlineSubsystemPC
EditPackages=OnlineSubsystemGameSpy
EditPackages=OnlineSubsystemLive
EditPackages=OnlineSubsystemSteamworks
then add your own line pointing to a folder named what ever you want but make sure it has a folder in it named Classes and it has the uc files you wnat to compile in it
ModEditPackages=MyTestProject
if you used that line then you are tellign udk you have a folder named
MyTestProject
located in your development/src folder and you want it to compile everything in there

Visual Studio Installer: How to make app.config a hidden file if I choose to add primary output instead of individual files?

Basically, I created a Visual Studio Installer project. I added a primary output to my project, which was great because it loaded in the dependencies and files automatically for me. The problem I'm facing is that I want to be able to mark my config file as a hidden file, but can't seem to figure out how.
When I go to View>File System it lists:
MyExternalAssembly.dll
Primary output from MyProject (Active)
So, is there a way to actually mark my config file as hidden during installation if I add a primary output project instead of the individual files?
I'm not sure if you really want to make it hidden. If you're worried about users looking at it, a more than average user will know how to un-hide things and pilfer around. So, that being said, if you want to keep users from seeing what's in the config you will need to encrypt the config. A good example of that can be found here:
http://www.davidhayden.com/blog/dave/archive/2005/11/17/2572.aspx
If you still want to hide the config, then you could try hiding it once the application is run for the first time.
Using: ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun with a click once application you can tell if this is the first time an application is run.
You could then use File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); to actually hide the app.config.
Which would result in:
if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
}

What's the easiest way to make a CC.NET local trigger to execute a program?

When the build fails, I'd like to execute a program that shoots me in the head with this. I've written the program already - I just need it to run when I break the build.
CCTray has the option to make a sound or icon - but not to run a file. Any simple ideas? I'd rather this not be an all day project. :)
CCTray allows you to run commands. In CCTry, go to File | Settings and then click on the Exec tab.
If you run Outlook, you can set up a rule that runs an application whenever you receive an email saying the build is broken. Just follow the rules wizard and you will find it (in Ootlook 2007 it's on the 3rd page of the wizard, in the select action part).
Cradiator has functionality to monitor build servers and do stuff when a build breaks. It doesn't have code to run an executable but it would be a cinch to download the code, change it and get what you want. Here's what I think is the quickest path to getting this done:
Download the source for Cradiator
Edit the DiscJockey.cs class
Add 1 line of code that starts your program (line 34) eg:
Configure Cradiator to monitor your build server (ie edit app.config and add your url) and run
if (newlyBrokenBuilds.Any())
{ // Add a line of code to start your program here eg
Process.Start("C:\\myprogram.exe");
}

Can a post-build step take me to a specific line of code?

I just wrote a little program which will be executed as a post-build step when I compile certain projects.
This program returns 0 for success, or some number for failure. In case of failure, Visual Studio then correctly outputs: "The command [...] exited with code n."
However, a single number is not always helpful. In my case, I actually want the error to point to a specific place in the source code. Is it possible to output a filename and line number in such a way that Visual Studio will actually let me just double-click on the error and get there instantly?
If the program you're running is a console application, I think its output will appear in the output pane. If the output is of the form
D:\dev\project\Code\MyClasscpp(68) : something terrible happened
then you can double-click on the line and the editor will open on the indicated line.

Resources