tags:

views:

97

answers:

1

I'm creating/updating resx files in TFS using ResXResourceWriter/ResXResourceReader which doesnt generate the .Designer.cs file. I saw that Resgen creates the .Designer.cs. How can i call that programmatically to generate the .Designer.cs at a certain TFS file path? Is it something like this?

ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\Bin\ResGen.exe"); startInfo.WindowStyle = ProcessWindowStyle.Minimized; startInfo.Arguments = "ResourceName.resx /publicClass /str:cs, Namespace, ResourceName, ResourceName.Designer.cs"; Process.Start(startInfo);

+1  A: 

I found out how to programmatically generate the .Designer.cs file.

    string[] UnmatchedElements;
CodeDomProvider CodeProvider = new Microsoft.CSharp.CSharpCodeProvider();
CodeCompileUnit Code = StronglyTypedResourceBuilder.Create(filePath,
                   ClassName, NameSpace, CodeProvider, false, out UnmatchedElements);

//System.Text.Encoding {System.Text.UTF8Encoding}
StreamWriter writer = new StreamWriter(DesignerfilePath  ); // Needs to be Designer file path
CodeProvider.GenerateCodeFromCompileUnit(Code, writer, new CodeGeneratorOptions());
writer.Close();`
jspence