Delete 'Trust Level="Medium"' element for package

--HG--
branch : dev
This commit is contained in:
Renaud Paquay 2010-12-06 22:03:10 -08:00
parent ce4c6d6ca5
commit cb8b5f3812
3 changed files with 59 additions and 2 deletions

View File

@ -134,6 +134,7 @@
<UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.FilterModuleBinaries" /> <UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.FilterModuleBinaries" />
<UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.FileUpdateLines" /> <UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.FileUpdateLines" />
<UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.ValidateExtensionProjectFiles" /> <UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.ValidateExtensionProjectFiles" />
<UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.XmlDelete" />
<Target Name="Package-Stage"> <Target Name="Package-Stage">
<CallTarget Targets="CompileMsBuildTasks"/> <CallTarget Targets="CompileMsBuildTasks"/>
@ -207,6 +208,9 @@
XPath="/configuration/system.web/compilation/@debug" XPath="/configuration/system.web/compilation/@debug"
Value="false" /> Value="false" />
<XmlDelete XmlFileName="$(StageFolder)\web.config"
XPath="/configuration/system.web/trust" />
<XmlUpdate XmlFileName="$(StageFolder)\web.config" <XmlUpdate XmlFileName="$(StageFolder)\web.config"
XPath="/configuration/system.web/machineKey/@validationKey" XPath="/configuration/system.web/machineKey/@validationKey"
Value="AutoGenerate" /> Value="AutoGenerate" />
@ -215,13 +219,13 @@
XPath="/configuration/system.web/machineKey/@decryptionKey" XPath="/configuration/system.web/machineKey/@decryptionKey"
Value="AutoGenerate" /> Value="AutoGenerate" />
<XmlUpdate XmlFileName="$(StageFolder)\Config\Diagnostics.config" <!--<XmlUpdate XmlFileName="$(StageFolder)\Config\Diagnostics.config"
XPath="/system.diagnostics/trace/@autoflush" XPath="/system.diagnostics/trace/@autoflush"
Value="false" /> Value="false" />
<XmlUpdate XmlFileName="$(StageFolder)\Config\Diagnostics.config" <XmlUpdate XmlFileName="$(StageFolder)\Config\Diagnostics.config"
XPath="/system.diagnostics/sources/source/@switchValue" XPath="/system.diagnostics/sources/source/@switchValue"
Value="Error" /> Value="Error" />-->
<!-- move over extra non-content files the csproj referenced --> <!-- move over extra non-content files the csproj referenced -->
<Copy SourceFiles="@(StageProjectAlteration-ExtraFiles->'$(SrcFolder)\Orchard.Web\%(Identity)')" <Copy SourceFiles="@(StageProjectAlteration-ExtraFiles->'$(SrcFolder)\Orchard.Web\%(Identity)')"

View File

@ -66,6 +66,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="XmlDelete.cs" />
<Compile Include="ValidateExtensionProjectFiles.cs" /> <Compile Include="ValidateExtensionProjectFiles.cs" />
<Compile Include="FileUpdateLines.cs" /> <Compile Include="FileUpdateLines.cs" />
<Compile Include="FilterModuleBinaries.cs" /> <Compile Include="FilterModuleBinaries.cs" />

View File

@ -0,0 +1,52 @@
using System;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace MSBuild.Orchard.Tasks {
public class XmlDelete : Task {
public string Namespace { get; set; }
public string Prefix { get; set; }
[Required]
public string XmlFileName { get; set; }
[Required]
public string XPath { get; set; }
public override bool Execute() {
try {
var document = new XmlDocument();
document.Load(this.XmlFileName);
var navigator = document.CreateNavigator();
var nsResolver = new XmlNamespaceManager(navigator.NameTable);
if (!string.IsNullOrEmpty(this.Prefix) && !string.IsNullOrEmpty(this.Namespace)) {
nsResolver.AddNamespace(this.Prefix, this.Namespace);
}
var expr = XPathExpression.Compile(this.XPath, nsResolver);
var iterator = navigator.Select(expr);
while (iterator.MoveNext()) {
iterator.Current.DeleteSelf();
}
using (var writer = new XmlTextWriter(this.XmlFileName, Encoding.UTF8)) {
writer.Formatting = Formatting.Indented;
document.Save(writer);
writer.Close();
}
}
catch (Exception exception) {
base.Log.LogErrorFromException(exception);
return false;
}
base.Log.LogMessage("Updated file '{0}'", new object[] { this.XmlFileName });
return true;
}
}
}