c# - 如何从命令行构建 .csproj 并将日志写入指定位置?

标签 c# visual-studio-2008 command-line build

虽然“无日志”构建似乎可以与类似的东西顺利工作

"c:\Program Files\Microsoft Visual Studio 9.0\Common7\ide\VCSExpress" Project1.csproj /build

以下失败:

"c:\Program Files\Microsoft Visual Studio 9.0\Common7\ide\VCSExpress" Project1.csproj /build /Log=log.txt

显示带有此文本的窗口:

Missing switch argument. Configuration name required for /build switch.

Use: vcsexpress [solutionfile | projectfile | anyfile.ext] [switches]

The first argument for vcsexpress is usually a solution file or project file. You can also use any other file as the first argument if you want to have the file open automatically in an editor. When you enter a project file, the IDE looks for an .sln file with the same base name as the project file in the parent directory for the project file. If no such .sln file exists, then the IDE looks for a single .sln file that references the project. If no such single .sln file exists, then the IDE creates an unsaved solution with a default .sln file name that has the same base name as the project file.

Command line builds: vcsexpress solutionfile.sln /build [ solutionconfig ] [ /project projectnameorfile [ /projectconfig name ] ] Available command line switches:

/Log Logs IDE activity to the specified file for troubleshooting. /ResetSettings Restores the IDE's default settings, optionally resets to the specified VSSettings file. /SafeMode Launches the IDE in safe mode loading minimal windows.

Product-specific switches:

To attach the debugger from the command line, use: VsJITDebugger.exe -p

[我正在使用 Visual Studio 2008 Express]

所以,问题是:

  • 有没有办法确保日志文件写在某处?

  • 或者 /Log 开关是否应该仅在 IDE 在 GUI 模式下运行时使用?如果是这样,是否有解决方法?

最佳答案

在底层,Visual Studio 使用 msbuild 对于所有它的构建魔法。据我所知,这也适用于 Express 版本。

如果您还没有,MSBuild 是 .NET SDK 的一部分。

调用 MSBuild 的优势在于直接进行构建 - 调用 VCSExpress 只会引入开销。

这是我使用过的 MSBuild 命令行:

msbuild.exe <solution> 
    /t:rebuild 
    /verbosity:quiet 
    /logger:FileLogger,Microsoft.Build.Engine;logfile=<filePath>

应该与 <project> 一样工作而不是 <solution> .

关于c# - 如何从命令行构建 .csproj 并将日志写入指定位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5174893/

相关文章:

c# - 如何将 RoutePattern 添加到 Endpoint 对象

c# - 为什么我的 C# 程序在从 Windows 7 命令行运行时经常暂停?

c++ - 转换方法签名

.net - LINQ-to-SQL 是否可以在插入时省略未指定的列,以便使用数据库默认值?

git - 是否有可能 'colorize' git 日志消息?

c# - 我如何为特定城市或国家设计伊斯兰祈祷时间小部件?

c# - 多行数据网格来处理集合中的集合?

c++ - 如何在类声明之外声明模板函数

python - 从 Python 完成后关闭控制台应用程序

windows - 从命令行通过 FTP 下载完整的远程目录