我最近在WPF中創建了一個應用程序。
我希望能夠更改應用程序標識,窗體標題,並從一個Builder(WinForms應用程序)進行其他自定義,編譯從源文件中的WPF應用程序的可執行使用C#從源文件編譯WPF應用程序?
可能有人請顯示的代碼示例關於如何使用C#編譯WPF應用程序?我知道如何使用CSharpCodeProvider
編譯.cs
源文件,但是可以使用CodeProvider從源文件編譯WPF嗎?
Anyhelp將高度讚賞
我最近在WPF中創建了一個應用程序。
我希望能夠更改應用程序標識,窗體標題,並從一個Builder(WinForms應用程序)進行其他自定義,編譯從源文件中的WPF應用程序的可執行使用C#從源文件編譯WPF應用程序?
可能有人請顯示的代碼示例關於如何使用C#編譯WPF應用程序?我知道如何使用CSharpCodeProvider
編譯.cs
源文件,但是可以使用CodeProvider從源文件編譯WPF嗎?
Anyhelp將高度讚賞
你需要看看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.");
}
}
哪裏可以找到生成的exe文件? – 2013-02-23 14:32:44
它將位於解決方案文件所在的Bin/Release文件夾中。 – Willem 2013-02-23 14:42:38
代碼執行但沒有任何反應?!我無法在發佈文件夾中看到該文件 – 2013-02-23 15:15:48
您正在尋找使用CSC.EXE是中包含的內容.NET框架的例子嗎? http://msdn.microsoft.com/en-us/library/vstudio/78f4aasd.aspx – kenny 2013-02-23 15:34:23