我有一個 PowerShell 腳本,它使用Add-Type并為-TypeDefinition我想,而不是定義$Source = @""@,定義$Source = script.cs.
這是可能的,如果是這樣,人們將如何去做呢?
$Source = Get-Content -Path $PSScriptRoot\script.cs -Raw
Add-Type -ReferencedAssemblies 'System', 'System.Runtime.InteropServices' -TypeDefinition $Source -Language CSharp
然后我稍后在 PS 腳本中使用 C# 腳本中的任何內容。我確實相信這是目前僅有的兩個重要領域
uj5u.com熱心網友回復:
Get-Content可以獲取檔案內容并將其用作字串。這是檔案的鏈接。例如:
$Source = Get-Content -Path .\path\to\script.cs -Raw
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/358640.html
