Build a .NET solution from PowerShell - visual-studio-2010

How do I build a .NET solution from the PowerShell command prompt?

You will have to call msbuild.exe passing in the solution file and appropriate arguments and do the build.
Also have a look at YDeliver ( https://github.com/manojlds/YDeliver ) for a build framework in Powershell. (Work in progress)

Related

Equivalent command to build (on WDK 7) with WDK 10

I have some really old scripts using the build command for compiling with WDK 7. A sample command to build a static library is:
build /F /g /w /b /c /Z /jpath %BUILDROOT%
What is equivalent command I can use to compile the same with WDK 10?
Also where can I find documentation on the usage of the build command.
While going through a MSDN documentation of MSBuild I came across this:
Important Starting in Windows Driver Kit (WDK) 8, MSBuild replaced the
Windows Build Utility (Build.exe).
So that's it - no build command for WDK 8+.
Converting the earlier project into a WDK 10 format - by generating the vcxproj files, I was able to build it.
Microsoft has replaced Build with MSBuild. The reference is MSBuild Reference. Note that Visual Studio uses MSBuild, even for WDK projects. It will take time to create VS projects but if the code is to edited more than a little it will be worth doing that.
There is a chance however that you can just change Build to MSBuild.

Can we compile and sign a windows 8 winjs application via commandline

Is there any way to create a windows 8 winjs .appx package file using command line?
Yes! Look for the MSBuild.exe executable in the .NET Framework folder. You run it like:
MSBuild.exe your/project.jsproj /p:Configuration=Release /t:Build /m
You can use "Debug" instead of "Release" and also "Deploy" instead of build (which will install the app locally, if not previously installed).
More at the MSBuild reference.
There are some usage samples in the Rainbowdriver project, which uses MSBuild to automatically test Windows 8 JS Apps using Selenium.

Macro Variable of VStudio in TeamCity not set

I have to use a Pre-Build event in Visual Studio in order to either copy a file from template version to compilable version, or to call a tool to translate the file - depending if I am in Debug or in Release mode.
As found here before, I used the debug switch
if $(ConfigurationName) == Debug goto :debug
$(SolutionDir)\Tools\MyTool\Translate -i $(ProjectDir)\Themes\Generic.Template.xaml -o $(ProjectDir)\Themes\Generic.xaml
goto :end
:debug
copy /y $(ProjectDir)\Themes\Generic.Template.xaml $(ProjectDir)\Themes\Generic.xaml
:end
Everything works fine, as long as I use my local Visual Studio. But when building with TeamCity, the Studio macro variables are not set correctly. Visual Studio itself is not installed on the build server. As build script we use f#make, which calls msbuild with the solution file. Calling the build batch locally also runs perfectly, so it seems that TeamCity hides these vars somehow.
Are there any known issues about that?
I do know that there are distinct differences between msbuild and devenv.exe when building against a .sln file. For example, msbuild driven builds will not build Visual Studio deployment projects. I can't say for sure what the effects are within prebuild steps.
I recommend changing your TeamCity build step to use devenv.exe instead of msbuild (probably will need a command line build step) and just see if it works better.
TeamCity provides some built build parameters that can help you find the correct path to devenv.exe on your agent(s). They are env.VS100COMNTOOLS and VS2010_Path.

Launch NSIS when building with Visual Studio

I have written a NSIS script for my project, and I would like to automatically create the setup file when I build the project. How can I do this with Visual Studio? Is there a way to pass parameters to the script?
I mean, I would like VS to pass the Assembly Version to the script. Right now, I have to manually edit a line in the script
VIProductVersion 1.5.0.1
and I sometime forget to update it. Is there a way to automate the process?
You can create defines and/or execute script instructions by using the /D and /X makensis parameters
NSIS can also read files with !searchparse
There are two questions here.
Q1. Launch NSIS when building with Visual Studio?
A1. Make a Post-build event that runs makensis on the .nsi file:
"C:\Program Files (x86)\NSIS\makensis.exe" "$(ProjectDir)\NSISInstaller\Installer.nsi"
Q2. Pass the Assembly Version to the post build event?
A2. Answered here: Determine assembly version during a post-build event
Combined solution should be:
"C:\Program Files (x86)\NSIS\makensis.exe" "$(ProjectDir)\NSISInstaller\Installer.nsi" /DPRODUCT_VERSION=$(AssemblyVersion)

Build from command line in Codegear 2009 IDE

Is it possible to automagically generate a MAKEFILE from the Codegear 2009 IDE? Or build a project from the command line?
No, but depending on your objective, you may be able to do what you want. If you simply want to do a build from a command line, this is possible. Because CB2009 uses msbuild, you can drive a build which uses all the same options and settings as an IDE build. There is a rsvars.bat file which sets all the environment variables you need and a shortcut to this batch file installed in the start menu called "RAD Studio Command Prompt" Once those are set, you can then call:
msbuild yourProjectFile.cbproj
This can then be integrated into a make system, continuous integration tool, or other automation.

Resources