我創建了一個PowerShell腳本部署以下斯科特Guthrie的例子我的web應用程序在這裏解釋Automate Everything (Building Real-World Cloud Apps with Azure) 使用這個MSBuild的調用來構建和發佈的Web應用程序運行的MSBuild從PowerShell中沒有指定.NET版本
& "$env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" $ProjectCsproj `
/p:VisualStudioVersion=12.0 `
/p:DeployOnBuild=true `
/p:PublishProfile=$PublishXmlFile `
/p:Password=$Password
由於你可以看到這個示例假設.Net框架版本4.0.30319,並且將在其他版本(或未來的.Net安裝)中失敗。
有沒有一種方法可以運行此MSBuild命令而不會假設任何特定的.Net版本?
是的,Get-ChildItem中的-filter參數比使用ForEach-Object更快。 –