Posts tagged ‘Visual Studio’

XNA Game Studio Express is out of Beta

XNA team today released XNA Game Studio Express 1.0 with XNA framework 1.0.

I am working with XNA for a couple of weeks, I will definetely post some samples and give more examples and reference about the framework in later posts.  I really liked that technology and the facilities it provides. Beside that my new project might use XNA, don’t know yet

Migration from ASP.NET 1.1 to ASP.NET 2.0

Although Visual Studio 2005 includes a conversion wizard for old projects, this does not work properly with web applications, because Microsoft removed support for web applications at the beginning. We don’t have a web project, we have a web site. The wizard tries to convert all the files to the new framework. This fails at first compilation, so many errors reported and I don’t want to fix all of these errors, since there exist an easier solution.

ASP.NET team stepped back and gave support for web projects through an add-in for Visual Studio 2005. Visual Studio 2005 Web Application Projects is the easiest way to migrate from ASP.NET 1.1 to ASP.NET 2.0. Because we are able to open our project file, visual studio converts only the project file. So all the files in ASP.NET 1.1 stays and only the project file changes. This is also useful because my code under source control doesn’t have to change.

However in Windows Vista, you don’t have the administrator rights by default and the installation of WAP fails. The solution to that problem is already defined here. The process is simply to write a bat file and run the bat file with administrator rights.

msiexec /i WebApplicationProjectSetup.msi

Another hidden .Net Tool usage basics: ilMerge

Ilmerge is a great utility for any .net developer. What it does is basically merge the assemblies. Let’s say you have three dll and one exe file, you can just merge those 4 files to 1 file using ilmerge. 
As a matter of fact, it is easy to use, you don’t need any recompilation or any other modification. You don’t need to provide installers since there is only one file.

Ilmerge exists in two versions one for .Net 1.1 and the other is .Net 2.0

Basic Usage

Usage: ilmerge [/lib:directory]* [/log[:filename]] [/keyfile:filename [/delaysig
n]] [/internalize[:filename]] [/t[arget]:(library|exe|winexe)] [/closed] [/ndebu
g] [/ver:version] [/copyattrs [/allowMultiple]] [/xmldocs] [/attr:filename] [/pu
blickeytokens] [/wildcards] [/zeroPeKind] [/allowDup:type]* /out:filename <prima
ry assembly> [<other assemblies>...]

Although the help explains very well, here is the usage.

C:\Program Files\Default Company Name\ILMergeBinaryDistribution7>Ilmerge /t:exe
/out:outputfile.exe file1.exe file2.dll

/t us used for the output of the file, exe is for a console application, winexe is for windows forms application and library is for the dlls.

/out is for the name of the output file.

the last parameters are the assemblies to be compined. Attention here is that the first one should be the exe one instead of the class library, becuase it merges the following files to the first file.

Advanced Usage

ILmerge is also usable as a class library for your project. What you need to do is to add the ilmerge executable as a reference and use the namespace of it to do some tasks. The class library is very similar to the console commands.

Execute batch commands before or after compilation using Pre-build or Post-build events

Have you ever wanted to execute a set of commands before or after the compilation, like copying the contents of the directory to the target compilation directory, or copy output of the compilation to a specified folder. This feature is integrated inside visual studio with the name; “Pre-build or Post-build event command line”. You access it from the project properties, in the build events tab.

ProjectProperties

If you want to do something before the compilation you enter the shell commands to pre-build, and post-build is the operations for after the compilation. We can use the predefined macros without hard copying the directory names. The edit window will guide us to find the macros.

Editing

Let’s say we want to copy the contents of the output directory to the root d:\. What we do is to edit the post-build event command with the command :

copy /D $(TargetPath) c:\

When we build it. We just get the error, “The command “copy D:\DEV\_Projects\sampleProj\bin\sample.dll d:\” exited with code 1.” Trying to execute the code from command line you get a similar error ‘The system cannot find the file specified.’

copy D:\\DEV\\_Projects\\sampleProj\\bin\\sample.dll d:"
The system cannot find the file specified.


What we forget is the need for the quotations for the long directory and filenames.

copy /D \"$(TargetPath)\" "c:\"

As a result, we can do whatever bat file operations before or after the compilation.