How can I create a Visual Studio 2008 solution manually?

For a project I am doing, I need to manually create a .net project. I am currently using StreamWriter

.sln, .csproj and base (empty for now) to create the class. I am also generating AssemblyInfo.cs class. I copied exactly the files and folder structure that VS.Net creates when creating an empty Windows Class Library project.

For some reason, when I try to open the .sln file, nothing happens. I can open the .csproj file fine, but the project won't compile. I don't get any error messages, nothing happens. I have checked all the files I create against those 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 creating a project? Is there anything else I could lose?

0


source to share


2 answers


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



0


source


Dave Markle had the correct answer.

I used the following code to create my file:

StreamWriter sw = File.CreateText(FileName);

      



This created the file correctly, but set the encoding incorrectly. I changed it to the following:

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

      

and it works great.

0


source







All Articles