How can I generate a Visual Studio 2008 solution manually?

For a project I am doing I need to manually create a .net project. I am currently using a StreamWriter to create the .sln, .csproj and base (empty for now) class. I am also generating the AssemblyInfo.cs class. I have copied exactly the files and folder structure VS.Net creates when you create an empty windows class library project.

For some reason when I try to open the .sln file nothing at all happens. I can open the .csproj file fine, but the project will not compile. I don't get any error messages, just nothing happens. I have checked all of the files I am creating against the ones created by Visual Studio using Beyond Compare and they are exactly the same except for the project name and GUID.

Does anyone know if Visual Studio is doing something behind the scenes when it creates a project? Is there something else I could be missing?

-------------Problems Reply------------

I would check the text encoding of your files. I believe .csproj files are encoded as UTF-8, but I could be wrong.

Dave Markle had the correct answer.

I was using the following code to create my file:

StreamWriter sw = File.CreateText(FileName);

This created the file correctly but did not set the encoding correctly. I changed it to this:

FileStream fs = File.Create(FileName);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);

and it works great.

Category:visual studio 2008 Views:2 Time:2008-12-17

Related post

Copyright (C), All Rights Reserved.

processed in 0.129 (s). 11 q(s)