【发布时间】:2014-01-21 23:56:45
【问题描述】:
我正在创建一个 C# hello world DLL 并使用内置的 powershell Add-Type 命令对其进行编译。这样做时,它会在包含 .dll 的目录中创建一个不需要的 .pdb 调试文件。
如何在使用 Add-Type 命令时禁止创建此 .pdb 文件。我知道在 Visual Studio 中我们可以通过一个选项禁用它,但似乎找不到合适的命令行语法。
这是示例 powershell 代码。从控制台运行,它将在 C:\ 上创建 DLL 以及 .pdb
Clear-Host
Add-Type -OutputAssembly C:\Knuckle.dll @"
using System;
namespace Knuckle
{
public class Dragger
{
public static void Main()
{
Console.WriteLine("Knuckle-Dragger was Here!");
}
}
}
"@
[Void][Reflection.Assembly]::LoadFile("C:\Knuckle.dll")
[Knuckle.Dragger]::Main()
结果
PS C:\Users\Knuckle-Dragger> [Knuckle.Dragger]::Main()
Knuckle-Dragger was Here!
【问题讨论】:
-
我认为 cmdlet 中没有内置方法可以跳过 pdb 文件,但说实话.. 添加
Remove-Item C:\Knuckle.dll -Force有那么难吗?
标签: c# powershell dll powershell-2.0 pdb-files