views:

134

answers:

3

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?

A: 

What happens when you run the sln/csproj under msbuild? That might give you better diagnostic info than VS'08

Paul Betts
A: 

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
This worked! Thank you.
DaveK
A: 

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.

DaveK