Compiling C# .Net from Command Line - c#-4.0

I'm trying to compile a c# .net project only using command line so that I could create a bat file to compile and run the Selenium tests. I exported the code from SVN. And I opened the command prompt and am able to restore packages using below command.
And then when I try to compile with msbuild it could not reference the dll added in through the nuget. I know in visual studio through package manager console I can use a command (update -reinstall) and make it work, but how to do this without visual studio.
==== bat file ======
REM Restore External Pacakages
nuget restore packages.config -PacakgesDirectory D:\Testproject\packages"
msbuid TestProject.sln

Basically you need to reference Msbuild executable
C:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe
OR
C:\Windows\Microsoft.Net\Framework64\v4.0.30319\MSBuild.exe
then you need to pass the .sln or .csproj file path (depends on your working folder) as parameter.
You can also specify the msbuild's targets ex. Clean, Rebuild, Build => As they exists in Visual Studio.
The final command could look like this:
Template:
{.NetFrameworkPath}\msbuild.exe {pathToSln} /t:{Build,Clean,Rebuild}
Examples
C:\Windows\Microsoft.Net\Framework64\v4.0.30319\MSBuild.exe TestProject.sln /t:Build
C:\Windows\Microsoft.Net\Framework64\v4.0.30319\MSBuild.exe TestProject.sln /t:Clean;Build

Related

How to use the StyleCop Plugin with the Resharper command line or "InspectCode" tool

We use Resharper with the StyleCop plugin. It works great inside Visual Studio without any problems.
Now I'd like to get statistics about our projects. I am building all our solutions from the command line and so far managed to get the output from the compiler (warnings) static code analysis (ex FxCop) and unit testing (results and coverage).
JetBrains offers a commandline tool that does code analysis for free (Link).
I'm using it and it works as expected.
The command line version does not recognize my StyleCop plugin and it's rules. That's obvious, it's a different folder. So I copied my plugins folder at
C:\Program Files (x86)\JetBrains\ReSharper\v8.2\Bin\Plugins\StyleCop 4.7
over from my Resharper installation into the command line tool's .\Bin\Plugins\StyleCop 4.7 and it works... the command line tool recognizes the plugin and loads it. However, the plugin then cannot find the StyleCop assemblies. They were default-installed into
C:\Program Files (x86)\StyleCop 4.7
Resharper itself in Visual Studio can somehow auto-detect them.
I tried copying the StyleCop assemblies to the same folder that the commandline exe is in. Nothing changed.
I tried copying the StyleCop assemblies next to the StyleCop Plugin assembly. That worked in a way. The StyleCop plugin found it's StyleCop assemblies, but the command line tool complained because it tried to load every single assembly in that folder as plugin.
So how do I get the command line tool to work with the StyleCop plugin?
If there is a better option, I do have a full license, I'm happy about any hint how to do this with the free command line tool or the normal Resharper full version as long as I can start it from a batch file without having to open the Visual Studio GUI.
Current State
Resharper recognized this is a problem with their tool. The Issue # is RSRP-436208.
It's not fixed as of 2017.1.1.
Workaround
When a Nuget package ( extension .nupkg ) is found in the tool's folder, it is expanded automatically in some temporary location. It's assemblies are then used with the tool.
So any *.nupkg of a plugin that resides in the tool folder should work.

Execute commands in visual studio 2012 like in makefiles

I have a driver code working for win2008 server compiled using wdk7.1.0. I converted the project to compile in visual studio 2012 with wdk8.1 and created sln and vcxproj files. I compiled successfully and generated .sys and .inf files.
My question is I have some files need to be copied to the output directory as part of build process automatically (after generating .inf and .sys files).
For wdk7.1.0, I wrote a makefile in which I executed "-copy /y src.out dest.out" and copied as part of compilation.
In wdk8.1 as I am compiling using visual studio, is there any way to execute these commands as part of build? like can I edit .sln/.vcxproj files etc etc.
Thanks in Advance
Venkatesh
You can use pre-build or post-build events properties of a project for this. You can call either a specific command or batch file to do such work.

Linking Qt5.0.2 to Visual Studio 2012

I am trying to link Qt5.0.2 to Visual Studio 2012 so I can do some GUI programming in C++ inside the Visual Studio environment. I have Downloaded and install ActivePerl and added Perl to the PATH environment variable and Create Perl file extension. I than downloaded Qt and installed it. I opened my Visual Studio Command prompt and changed to my C:Qt\Qt5.0.2 directory. Inside this directory I have a 5.0.2 folder, Tools folder, License folder, MaintenanceTool files and so on. Once inside of my C:Qt\Qt5.0.2 directory, I inserted this command: configure -debug-and-release -opensource -shared -platform win32-msvc2012. I get an error saying 'configure' is not recognized as a an internal or external command, operational program or batch file.
I have no idea what this means and what to do. I have been following my instructions from this aticle http://briolidz.wordpress.com/2012/03/07/compiling-qt-with-visual-studio-2010/
Can anyone help me with this?
Thanks
If I was you, I would follow instructions posted here http://qt-project.org/wiki/Building_Qt_5_from_Git

Creating a dynamic link library with Visual C++ in Visual Studio

I have a link script that links a bunch of obj and lib files into a dll. I'm trying to do the same thing in Visual Studio, but without any luck. Problem is that the project doesn't have any source files. The project needs to take all the lib and obj files and link them to a dll.
I'm not sure you can do it from Visual Studio, but you can do it from the Visual Studio Command Prompt with a command like this:
link /OUT:"Dll.dll" /DLL obj1.obj obj2.obj lib1.lib lib2.lib
Create Makefile project. In VC++ 2010: Visual C++ - General - Makefile Project. In the Project properties open Build command line: Configuration properties - NMake - Build command line. Enter the script name here. When you execute Build command, this script is executed.

How to use msbuild to create csx output for Azure SDK 1.8?

I have a Visual Studio project with an Azure Cloud project that has one Web Role for a WCF Service. Rather than creating a cspkg by using the Package command in Visual Studio or with cspack, I need to create the same output that is in the project's csx folder with msbuild. However, if I run the following command in msbuild, the output doesn't have the same folder structure as the csx folder:
msbuild MyAzureProject.ccproj /p:configuration=debug /maxcpucount /p:outdir="c:\OutDir" /p:overwritereadonlyfiles=true /p:targetprofile="Cloud"
Instead it creates a _PublishedWebsites folder. Does anyone know how to create the contents of the csx folder manually by using the msbuild command-line (i.e. csx/roles/MyAzureRole/approot)?
You're just missing the targets switch.
Here's what works for me.
msbuild MyAzureProject.ccproj /p:configuration=debug /maxcpucount /p:outdir="c:\OutDir" /p:overwritereadonlyfiles=true /p:targetprofile="Cloud" /target:Clean;Publish

Resources