Custom PreBuild and PostBuild Macros - msbuild

I am working on a PreBuild and PostBuild Events for My Custom Project Type. The events are running fine. While working on adding Custom Macros for my Build, those macros are automatically getting evaluated as empty even before the actual PreBuild or PostBuild action occurs.
I added a new task to set values for those Macros as MSBuild Properties with a Different Task which sets the MSBuild properties as a part of Outputs, and scheduled it to run before the PreBuild Task runs. The properties are getting set, however it looks like there is some other inbuilt task which is Evaluating the PreBuild string and replacing the locations where custom macros are used as Empty strings.
Is there a way call my Task which sets actual values for those custom macros and then evaluate the PreBuild and PostBuild Event text.

Related

Add a custom command (with a custom icon)

Is it possible in IntelliJ/WebStorm to add a custom icon somewhere in a toolbar that runs a custom command, e.g. CLI?
If yes, is it also possible to add this in the projects .idea so that my team members also have this icon without any configuration?
My goal is to add some custom Git commands.
I'm not sure about icons (never used them myself) .. but as far as I'm aware this would not be easily to copy it over (custom toolbar actions) as it would be an IDE-wide setting which you cannot copy as separate file (it will be a part of actual IDE customisation config -- hence uniqueness for each user). Therefore tool buttons are rather user-specific and not recommended way if you want to share this stuff or update it in a future with not much hassle (at very least to have such possibility).
Instead you could just use External Tools functionality for executing your custom CLI commands -- this will also be an IDE-wide setting but each group is stored in separate file.. so others will have to copy such file into IDE config folder. Each such tool can then be accesses via context menus (it has 4 places where such commands can be placed: Tools menu and 3 context menus).
Another alternative (that could be shared as part of the actual project) is to code all your custom CLI commands as Gulp/Grunt/NPM script tasks and execute them that way. Since such files are usually placed in project root (or subfolder) .. they can be easily shared via VCS.
All tasks/scripts are loaded from actual task definition files (package.json/gulpfile.js/etc) .. so they are not stored inside .idea subfolder. But you can create Run/Debug Configurations (to quickly run specific task with possible custom parameters etc) .. and such stuff is placed inside .idea (make sure to mark them as "Shared" .. otherwise they will be stored inside user-specific and not-VCS-shareable workspace.xml file rather than individual files).

Can I capture any errors from Debug > Compile with VBA (Excel 2010)?

I found this code (link below) very useful but is it possible to suppress compile error msgboxes and also capture the compile errors somehow?
Can I compile VBA on workbook open?
For example I am currently reloading common modules in a list of workbooks. The compile code runs after dynamically reloading all the modules into each file, before moving on to the next file. I get a series of msgboxes within VBA Editor, I have to click OK for each box, but I can't stop the code at that point.
Ideally, I want to be able to halt (or pause) mid-process and take action within the file to correct the errors, before continuing with the process and updating the modules in the remaining files.
Is this possible?

VSTO: Specify Word Document During Debugging Development

In Visual Studio VSTO, how can I specify the document to open each time I run the project to debug it?
By default, it always opens a blank document and of course I want to test against features that would already be present in a document.
I tried as Cor_Blimey suggested but it opens only the specified when something changes (haven't figured what yet). In addition breakpoints don't work at least in VS2013 implementing the upper solution.
So what I did is to open the specific debugging/testing file each time the add-in is started up.
It works excellent, breakpoints are functional, no blank workbook is loaded and changes in a sheet a available in the next debugging session.
In order to avoid that the file is opened in the released add-in I put it in #if DEBUG.
More information about that method are here but it has as to be used with precaution as described here.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
#if (DEBUG)
this.Application.Workbooks.Open("C:\\Users\\c563368\\Documents\\Visual Studio 2013\\Projects\\...\\debug.xls");
#endif
}
But there is one disadvantage, as long as you debugging environment (visual studio) is running, Office will always open the add-in build from the debug folder.
You can avoid this by running an the office application as external program, as described here.
You need to use the command line you can set to run on a successful build (there is no way to only get it to run on Debug (as in F11) and you cannot set it on a per Configuration basis. However, there is a good workaround to get it to only do things on the Debug configuration etc.
The basic behaviour is:
Open the solution. Open the project's properties. Go to Build Events. In Post-Build Event Command Line enter in the path to Word (e.g. "C:\Program Files (x86)\Microsoft Office\Office14\Winword") (or if it is in your %Path% then just Winword) and pass in the path to the document you want opened as an argument. This will open Word and the document on every successful build (you can set the trigger to being all builds, whether successful or otherwise etc)
What I prefer to do, however, is simply point it to a batch file, passing in the details about the build event as arguments to the batch file. Then, within the batch file, I run the logic to decide if it should launch Word, open a document etc.
For example, you can point it to
$(ProjectDir)buildScript.bat "$(ConfigurationName)"
Then within the batch file have something like
if %1=="Debug - Excel" "C:\Program Files (x86)\Microsoft Office\Office14\excel.exe" "%~dp0\testbook.xlsx"
This will run a batch file called buildScript in the project directory. The first argument (%1 to access in the batch file) will be the configuration. You can therefore set the batch file to launch Word and pass in the document as the argument if the config is e.g. "Debug" but not if it is "Release", thereby sidestepping the limitation within VS2012 Post-Build Event command line.
Edit:
A list of switches for Word can be found at http://support.microsoft.com/kb/210565
What you need to instruct Word to do will depend on the type of addin you are making:
If it is a standard COM addin then, so long as the DLL is registered and you have set the registry entries (or selected it in the Word addin settings) to open the addin then it should open when Word opens.
If it is an addin document, however, then the procedure is different -> try playing with the commnd switches to instruct Word to open the particular addin document.
I am more familiar with Excel COM addins, so you will have to experiment with the specificities of a Word addin. But the basic principles are to use the post-build event commnd line, coupled with the right switches and arguments to Winword.
Hope that helps.
The simpliest way to achive it is to replace .docx / .xlsx file in solution location

IntelliJ - show all compilation errors automatically in the project when code is changed

In Eclipse, when I make any code changes it automatically shows all compilation errors in the workspace in a console. It seems like in IntelliJ I have to make/build the project in order to see any compilation errors. Is there a window/tab to show all compilation errors?
Nowadays you have the same option as in eclipse to have automatic builds when you save.
Edit
Any changes in the editor will now trigger a compilation either when Ctrl+s is pressed or after a short interval.
This first image will show a main method and a class with a simple print method. No compilation errors.
In the next image I have removed the parameter message in the print method. That's the only thing I did, I did not even save I just waited a couple of seconds. And then suddenly the compilation error is shown below because the caller of the method has now supplied too many arguments.

TFS 2010 : Use the label name in build number format

I'm trying to setup a build with TFS 2010. I want the build number format to be something like $(BuildDefinitionName)_$(version) where $(Version) is the version (label or changeset) specified in the "Get Version" field in the "Queue Build" dialog. If there's no specific version, I would like the version to be latest.
I googled for that but I'm new to msbuild and TFS build so I'm not sure what I should look for to get started.
Thanks.
The Microsoft.TeamFoundation.Build.Workflow.Activities.UpdateBuildNumber activity in your build template (e.g. DefaultTemplate.xaml) is what does the work of transforming your build number format string. It takes any of the parameters listed here, however, the version (your changeset or label) is not one of the supported tags.
One workaround I've found that does not require custom code is to edit the BuildNumberFormat argument immediately before the Update Build Number activity uses it.
Open up the xaml template using the GUI editor and find the Update Build Number activity at the top.
Find the Primitives -> Assign activity in the Toolbox. Drag and drop that just above the Update Build Number.
Edit the Assign activity to assign the value String.Format("$(BuildDefinitionName)_$(Date:yyyyMMdd)_{0}$(Rev:.r)", BuildDetail.SourceGetVersion) to BuildNumberFormat. The SourceGetVersion will pull the changeset number or label used to trigger the build. If nothing is specified in the Get Version dialog when you're queuing your build then the changeset number is used by default (e.g. C16044).
this is a good start
http://www.ewaldhofman.nl/post/2010/06/01/Customize-Team-Build-2010-e28093-Part-10-Include-Version-Number-in-the-Build-Number.aspx