![](/img/trans.png)
[英]Any way to check if a css file is referenced somewhere in the solution? Visual Studio
[英]Any quick way to run a file in Visual Studio?
有沒有快速方法在VS 2008中使用Main方法運行文件(.cs)?
通常,您需要測試一些模型代碼,Going Alt + f7(Project-> ProjectName Properties)並從下拉列表中更改Startup對象非常麻煩。
讓自己成為SnippetCompiler ,它可以運行片段(不在VS內部,但足夠接近)並且可以幫助你。
那些代替模型,把它們寫成單元測試。 您可以快速運行它們而無需更改入口點。 測試可以留待以后的更改。 您可以使用Asserts和Trace Writes,而不是寫入控制台。
為了編譯一個文件C#程序,我創建了一個.bat文件,在該文件中我拖放.cs文件並在.cs文件目錄中獲取.exe文件。
SET PATH=%PATH%;C:\WINDOWS\Microsoft.NET\Framework\v3.5
cd %~d1\
cd "%~p1"
csc %1
您可以在Visual Studio宏中使用此.bat文件來編譯活動的.cs文件並運行該應用程序。
Sub RunCS()
If Not ActiveDocument.FullName.EndsWith(".cs") Then
Return
End If
REM Path to batch file
Dim compileScript = "C:\dev\compileCS.bat"
Dim compileParams As System.Diagnostics.ProcessStartInfo
compileParams = New ProcessStartInfo(compileScript, Chr(34) & ActiveDocument.FullName & Chr(34))
Dim compiling As System.Diagnostics.Process
compiling = System.Diagnostics.Process.Start(compileParams)
compiling.WaitForExit()
Dim programFile As String
programFile = ActiveDocument.FullName.Substring(0, ActiveDocument.FullName.Length - 3) + ".exe"
Dim running As System.Diagnostics.Process
running = System.Diagnostics.Process.Start(programFile)
End Sub
這將只運行所有代碼都在一個文件中的程序。 如果您想快速更改項目,可以將解決方案的啟動項目更改為當前選擇
我保留了一個沙盒解決方案,它有一個控制台項目和我經常使用的其他小項目類型。 Snippet Tools很不錯,但通常不會像調試等整個Visual Studio一樣。
Snippy ,最初由Jon Skeet(我相信潛伏在這里)並由Jason Haley進一步開發。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.