Reputation: 5037
I recently created an application in WPF.
I want to be able to change the application Logo, The Form title and make other customizations from a Builder (winforms app) that compiles the WPF application from source file to Executable
Could someone please show a code example on how can I compile a WPF application using C# ? I know how to compile a .cs
source file using CSharpCodeProvider
but is it possible to use the CodeProvider to compile a WPF from source file ?
Anyhelp would be highly appreciated
Upvotes: 0
Views: 540
Reputation: 9476
You need to have a look at MSBuild
using (System.Diagnostics.Process process = new System.Diagnostics.Process())
{
string workingDirectoryPath = "PathToYourSolutionFile"
string resultsFileMarker = workingDirectoryPath + @"\DotNetBuildResult.txt";
process.StartInfo.FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe";
process.StartInfo.Arguments = @"YourSolutionName.sln /nologo /fileLogger /fileloggerparameters:errorsonly;LogFile=""" + resultsFileMarker + @""" /noconsolelogger /t:clean;rebuild /verbosity:normal /p:Configuration=Release;Platform=x86";
process.StartInfo.WorkingDirectory = workingDirectoryPath;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
process.Close();
process.Dispose();
using (StreamReader resultsStreamReader = new FileInfo(resultsFileMarker).OpenText())
{
results = resultsStreamReader.ReadToEnd();
}
if (results.Trim().Length != 0)
{
System.Diagnostics.Process.Start(resultsFileMarker);
errorEncountered = true;
throw new Exception("Error were errors rebuilding the .Net WPF app - please check the log file that has just opened.");
}
}
Upvotes: 3