我想將內容添加到Web配置中,但前提是該內容尚不存在。這是我做的:檢查內容是否在web.config中
$webconfig = Get-Content F:\whatever\web.config
if ($webconfig -notlike "*WebGrease*") {
// do stuff here
}
現在我的問題是:即使在web.config中包含有類似
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
它仍然進入代碼爲「在這裏做的東西」。問題是什麼? 「不喜歡」是否適用於多行字符串?
'Get-Content'將行放入一個數組中,所以'$ webconfig'不是這裏的多行字符串 – arco444
啊。感謝那。在調試它看起來像一個字符串。這騙了我 –