mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
40
Orchard.proj
40
Orchard.proj
@@ -63,7 +63,7 @@
|
||||
<CallTarget Targets="Gallery-Stage"/>
|
||||
<CallTarget Targets="Gallery-Setup"/>
|
||||
</Target>
|
||||
|
||||
|
||||
<!-- Building -->
|
||||
|
||||
<Target Name="Clean">
|
||||
@@ -120,9 +120,11 @@
|
||||
<UsingTask AssemblyFile="$(MsBuildTasksFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.StageProjectAlteration" />
|
||||
<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.ValidateExtensionProjectFiles" />
|
||||
|
||||
<Target Name="Package-Stage">
|
||||
<CallTarget Targets="CompileMsBuildTasks"/>
|
||||
<CallTarget Targets="ValidateProjectFiles"/>
|
||||
|
||||
<ItemGroup>
|
||||
<SqlCe-Native-Binaries-x86 Include="$(SqlCeFolder)\x86\*"/>
|
||||
@@ -134,8 +136,8 @@
|
||||
<Stage-Media Include="$(SrcFolder)\Orchard.Web\Media\OrchardLogo.png" />
|
||||
<Stage-PoFiles Include="$(SrcFolder)\Orchard.Web\**\*.po" />
|
||||
<Stage-Core Include="$(WebSitesFolder)\Orchard.Core\**\*" Exclude="$(WebSitesFolder)\Orchard.Core\**\bin\**\*" />
|
||||
<Stage-Themes Include="$(ThemesSrcFolder)\**\*" Exclude="@(Stage-Bin-Exclude);$(ThemesSrcFolder)\*.*;$(ThemesSrcFolder)\*.*;$(ThemesSrcFolder)\bin\**;$(ThemesSrcFolder)\obj\**;$(ThemesSrcFolder)\*.*;$(ThemesSrcFolder)\Properties\**" />
|
||||
<Stage-Themes-Binaries Include="$(ThemesSrcFolder)\*\**\bin\*" />
|
||||
<Stage-Themes Include="$(ThemesSrcFolder)\**\*" Exclude="@(Stage-Bin-Exclude);$(ThemesSrcFolder)\*.*;$(ThemesSrcFolder)\*.*;$(ThemesSrcFolder)\bin\**;$(ThemesSrcFolder)\obj\**;$(ThemesSrcFolder)\*.*;$(ThemesSrcFolder)\Properties\**" />
|
||||
<Stage-Themes-Binaries Include="$(ThemesSrcFolder)\*\**\bin\*" />
|
||||
|
||||
<Stage-Module-Exclude Include="@(Stage-Web);@(Stage-Core);@(Stage-Themes);$(WebSitesFolder)\PackageIndexReferenceImplementation\**\*"/>
|
||||
|
||||
@@ -195,11 +197,11 @@
|
||||
<XmlUpdate XmlFileName="$(StageFolder)\web.config"
|
||||
XPath="/configuration/system.web/machineKey/@validationKey"
|
||||
Value="AutoGenerate" />
|
||||
|
||||
|
||||
<XmlUpdate XmlFileName="$(StageFolder)\web.config"
|
||||
XPath="/configuration/system.web/machineKey/@decryptionKey"
|
||||
Value="AutoGenerate" />
|
||||
|
||||
|
||||
<XmlUpdate XmlFileName="$(StageFolder)\Config\Diagnostics.config"
|
||||
XPath="/system.diagnostics/trace/@autoflush"
|
||||
Value="false" />
|
||||
@@ -232,7 +234,7 @@
|
||||
$(StageFolder)\**\Modules\Orchard.MultiTenancy\**;
|
||||
$(StageFolder)\**\Modules\Orchard.Search\**;
|
||||
" />
|
||||
|
||||
|
||||
<MsDeploy-Folder-Input Include="$(StageFolder)\**\*" Exclude="$(StageFolder)\**\bin\**\*.xml;@(MsDeploy-Exclude-Modules)" />
|
||||
<MsDeploy-Parameters Include="$(LibFolder)\msdeploy\*.xml;$(LibFolder)\msdeploy\*.sql"/>
|
||||
</ItemGroup>
|
||||
@@ -321,12 +323,24 @@
|
||||
<Exec Command=""$(GalleryFolder)\bin\Orchard.exe" package create Orchard.MultiTenancy "$(GalleryArtifactFolder)"" WorkingDirectory="$(GalleryFolder)"/>
|
||||
<Exec Command=""$(GalleryFolder)\bin\Orchard.exe" package create Orchard.Search "$(GalleryArtifactFolder)"" WorkingDirectory="$(GalleryFolder)"/>
|
||||
</Target>
|
||||
|
||||
<!-- Version -->
|
||||
|
||||
<!-- ValidateProjectFiles-->
|
||||
<Target Name="ValidateProjectFiles">
|
||||
<CallTarget Targets="CompileMsBuildTasks"/>
|
||||
|
||||
<ItemGroup>
|
||||
<Validate-ProjectFiles Include="$(ModulesSrcFolder)\**\*.csproj;$(ThemesSrcFolder)\**\*.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ValidateExtensionProjectFiles Files="@(Validate-ProjectFiles)"/>
|
||||
|
||||
</Target>
|
||||
|
||||
<!-- SetVersion -->
|
||||
<!-- Update all AssemblyInfo.cs and module.txt files to contain $(Version) -->
|
||||
<Target Name="SetVersion" Condition="$(Version) != ''">
|
||||
<CallTarget Targets="CompileMsBuildTasks"/>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Version-AssemblyInfos Include="$(SrcFolder)\**\AssemblyInfo.cs" />
|
||||
<Version-Modules Include="$(SrcFolder)\**\Module.txt" />
|
||||
@@ -338,10 +352,10 @@
|
||||
ReplacementText="${1}${2}:${3}$(Version)"
|
||||
IgnoreCase="True"/>
|
||||
|
||||
<FileUpdateLines Files="@(Version-Themes)"
|
||||
Regex="^(orchardversion|version)(\s*):(\s*)(.*)"
|
||||
ReplacementText="${1}${2}:${3}$(Version)"
|
||||
IgnoreCase="True"/>
|
||||
<FileUpdateLines Files="@(Version-Themes)"
|
||||
Regex="^(orchardversion|version)(\s*):(\s*)(.*)"
|
||||
ReplacementText="${1}${2}:${3}$(Version)"
|
||||
IgnoreCase="True"/>
|
||||
|
||||
<FileUpdateLines Files="@(Version-AssemblyInfos)"
|
||||
Regex="^\[assembly:(\s)*(AssemblyVersion|AssemblyFileVersion)(\s)*\("(.*)"\)(\s)*\]"
|
||||
|
@@ -26,7 +26,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@@ -105,7 +105,7 @@
|
||||
<Content Include="Styles\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="Views\EditorTemplates\Parts\CreateTag.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\CreateTag.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -120,8 +120,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Account\RegistrationPending.cshtml" />
|
||||
<None Include="Views\EditorTemplates\Parts\User.Edit.cshtml" />
|
||||
<None Include="Views\EditorTemplates\Parts\User.Create.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\User.Edit.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\User.Create.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -66,9 +66,9 @@
|
||||
</Content>
|
||||
<Content Include="TheAdmin\Views\Pager.cshtml" />
|
||||
<Content Include="TheAdmin\Views\OrchardVersion.cshtml" />
|
||||
<None Include="Web.config">
|
||||
<Content Include="Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</Content>
|
||||
<Content Include="TheAdmin\Views\Menu.cshtml" />
|
||||
<Content Include="TheThemeMachine\Views\Branding.cshtml" />
|
||||
<Content Include="TheThemeMachine\Views\BadgeOfHonor.cshtml" />
|
||||
|
@@ -95,11 +95,11 @@ namespace Orchard.Commands {
|
||||
}
|
||||
catch (OrchardCommandHostRetryException e) {
|
||||
// Special "Retry" return code for our host
|
||||
output.WriteLine("{0} (Retrying...)", e.Message);
|
||||
output.WriteLine(T("{0} (Retrying...)", e.Message));
|
||||
return CommandReturnCodes.Retry;
|
||||
}
|
||||
catch (Exception e) {
|
||||
OutputException(output, e);
|
||||
OutputException(output, T("Error executing command \"{0}\"", string.Join(" ", args)), e);
|
||||
return CommandReturnCodes.Fail;
|
||||
}
|
||||
}
|
||||
@@ -111,11 +111,11 @@ namespace Orchard.Commands {
|
||||
}
|
||||
catch (OrchardCommandHostRetryException e) {
|
||||
// Special "Retry" return code for our host
|
||||
output.WriteLine("{0} (Retrying...)", e.Message);
|
||||
output.WriteLine(T("{0} (Retrying...)", e.Message));
|
||||
return CommandReturnCodes.Retry;
|
||||
}
|
||||
catch (Exception e) {
|
||||
OutputException(output, e);
|
||||
OutputException(output, T("Error starting up Orchard command line host"), e);
|
||||
return CommandReturnCodes.Fail;
|
||||
}
|
||||
}
|
||||
@@ -129,20 +129,42 @@ namespace Orchard.Commands {
|
||||
return CommandReturnCodes.Ok;
|
||||
}
|
||||
catch (Exception e) {
|
||||
OutputException(output, e);
|
||||
OutputException(output, T("Error shutting down Orchard command line host"), e);
|
||||
return CommandReturnCodes.Fail;
|
||||
}
|
||||
}
|
||||
|
||||
private void OutputException(TextWriter output, Exception e) {
|
||||
for (int i = 0; e != null; e = e.InnerException, i++) {
|
||||
if (i > 0) {
|
||||
output.WriteLine("---- Inner Exception -----------------------------------------------------------------------");
|
||||
}
|
||||
output.WriteLine("Error: {0}", e.Message);
|
||||
output.WriteLine(" Exception Type: {0}", e.GetType().FullName);
|
||||
output.WriteLine("{0}", e.StackTrace);
|
||||
private void OutputException(TextWriter output, LocalizedString title, Exception exception) {
|
||||
// Display header
|
||||
output.WriteLine();
|
||||
output.WriteLine(T("{0}", title));
|
||||
output.WriteLine(T("--------------------------------------------------------------------------------"));
|
||||
|
||||
// Push exceptions in a stack so we display from inner most to outer most
|
||||
var errors = new Stack<Exception>();
|
||||
for (var scan = exception; scan != null; scan = scan.InnerException) {
|
||||
errors.Push(scan);
|
||||
}
|
||||
|
||||
// Display inner most exception details
|
||||
exception = errors.Peek();
|
||||
output.WriteLine(T("{0}", exception.Message));
|
||||
output.WriteLine();
|
||||
output.WriteLine(T("Exception Details: {0}: {1}", exception.GetType().FullName, exception.Message));
|
||||
output.WriteLine();
|
||||
output.WriteLine(T("Stack Trace:"));
|
||||
output.WriteLine();
|
||||
|
||||
// Display exceptions from inner most to outer most
|
||||
foreach(var error in errors) {
|
||||
output.WriteLine(T("[{0}: {1}]", error.GetType().Name, error.Message));
|
||||
output.WriteLine(T("{0}", error.StackTrace));
|
||||
output.WriteLine();
|
||||
}
|
||||
|
||||
// Display footer
|
||||
output.WriteLine("--------------------------------------------------------------------------------");
|
||||
output.WriteLine();
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
|
||||
|
@@ -66,6 +66,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ValidateExtensionProjectFiles.cs" />
|
||||
<Compile Include="FileUpdateLines.cs" />
|
||||
<Compile Include="FilterModuleBinaries.cs" />
|
||||
<Compile Include="StageProjectAlteration.cs" />
|
||||
|
179
src/Tools/MSBuild.Orchard.Tasks/ValidateExtensionProjectFiles.cs
Normal file
179
src/Tools/MSBuild.Orchard.Tasks/ValidateExtensionProjectFiles.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace MSBuild.Orchard.Tasks {
|
||||
/// <summary>
|
||||
/// Validate various aspect of a set of Module/Theme project files
|
||||
/// </summary>
|
||||
public class ValidateExtensionProjectFiles : Task {
|
||||
public ITaskItem[] Files { get; set; }
|
||||
|
||||
public override bool Execute() {
|
||||
bool result = true;
|
||||
|
||||
foreach (var item in Files) {
|
||||
try {
|
||||
ValidateFile(item);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.LogError("Error validating project file \"{0}\"", item);
|
||||
Log.LogErrorFromException(e);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ValidateFile(ITaskItem item) {
|
||||
Log.LogMessage("Validating \"{0}\"", item);
|
||||
|
||||
var errors = new Validator(item).Validate();
|
||||
|
||||
if (errors.Any()) {
|
||||
foreach (var error in errors) {
|
||||
Log.LogError("", "", "", error.FileName, error.LineNumber, error.ColumnNumber, 0, 0, "{0}", error.Message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.LogMessage("Project file \"{0}\" is valid", item);
|
||||
}
|
||||
}
|
||||
|
||||
public class Validator {
|
||||
private const string Xmlns = "http://schemas.microsoft.com/developer/msbuild/2003";
|
||||
private static readonly XName Project = XName.Get("Project", Xmlns);
|
||||
private static readonly XName PropertyGroup = XName.Get("PropertyGroup", Xmlns);
|
||||
private static readonly XName ItemGroup = XName.Get("ItemGroup", Xmlns);
|
||||
private static readonly XName ProjectTypeGuids = XName.Get("ProjectTypeGuids", Xmlns);
|
||||
private static readonly XName OutputPath = XName.Get("OutputPath", Xmlns);
|
||||
private static readonly XName None = XName.Get("None", Xmlns);
|
||||
private static readonly XName Content = XName.Get("Content", Xmlns);
|
||||
private static readonly XName Include = XName.Get("Include"); // No XmlNs: this is an attribute
|
||||
private static readonly XName CodeAnalysisRuleSet = XName.Get("CodeAnalysisRuleSet", Xmlns);
|
||||
|
||||
private static readonly Guid[] MvcGuids = new Guid[] {
|
||||
new Guid("{F85E285D-A4E0-4152-9332-AB1D724D3325}") /* MVC2 */,
|
||||
new Guid("{E53F8FEA-EAE0-44A6-8774-FFD645390401}") /* MVC3 */
|
||||
};
|
||||
|
||||
private readonly ITaskItem _item;
|
||||
private readonly List<Error> _validationErrors = new List<Error>();
|
||||
|
||||
public Validator(ITaskItem item) {
|
||||
_item = item;
|
||||
}
|
||||
|
||||
public IEnumerable<Error> Validate() {
|
||||
XDocument document = XDocument.Load(_item.ItemSpec, LoadOptions.SetLineInfo);
|
||||
CheckProjectType(document);
|
||||
CheckOutputPath(document);
|
||||
//CheckCodeAnalysisRuleSet(document);
|
||||
CheckContentFiles(document);
|
||||
return _validationErrors;
|
||||
}
|
||||
|
||||
private void AddValidationError(XElement element, string message) {
|
||||
var error = new Error {
|
||||
Message = message,
|
||||
XElement = element,
|
||||
FileName = _item.ItemSpec,
|
||||
LineNumber = (element as IXmlLineInfo).LineNumber,
|
||||
ColumnNumber = (element as IXmlLineInfo).LinePosition,
|
||||
};
|
||||
_validationErrors.Add(error);
|
||||
}
|
||||
|
||||
private void CheckContentFiles(XDocument document) {
|
||||
var elements = document
|
||||
.Elements(Project)
|
||||
.Elements(ItemGroup)
|
||||
.Elements(None);
|
||||
|
||||
foreach (var element in elements) {
|
||||
var include = (element.Attribute(Include) == null ? null : element.Attribute(Include).Value);
|
||||
bool isValid = string.IsNullOrEmpty(include);
|
||||
if (!isValid) {
|
||||
string message = string.Format(
|
||||
"\"{0}\" element name for include \"{1}\" should be \"{2}\".",
|
||||
element.Name.LocalName, include, Content.LocalName);
|
||||
AddValidationError(element, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckCodeAnalysisRuleSet(XDocument document) {
|
||||
const string orchardbasiccorrectnessRuleset = "OrchardBasicCorrectness.ruleset";
|
||||
|
||||
var elements = document
|
||||
.Elements(Project)
|
||||
.Elements(PropertyGroup)
|
||||
.Elements(CodeAnalysisRuleSet);
|
||||
|
||||
foreach (var element in elements) {
|
||||
var filename = Path.GetFileName(element.Value);
|
||||
bool isValid = StringComparer.OrdinalIgnoreCase.Equals(filename, orchardbasiccorrectnessRuleset);
|
||||
if (!isValid) {
|
||||
string message = string.Format(
|
||||
"\"{0}\" element should be \"{1}\" instead of \"{2}\".",
|
||||
element.Name.LocalName, orchardbasiccorrectnessRuleset, element.Value);
|
||||
AddValidationError(element, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckOutputPath(XDocument document) {
|
||||
var elements = document
|
||||
.Elements(Project)
|
||||
.Elements(PropertyGroup)
|
||||
.Elements(OutputPath);
|
||||
|
||||
foreach (var element in elements) {
|
||||
bool isValid =
|
||||
StringComparer.OrdinalIgnoreCase.Equals(element.Value, "bin") ||
|
||||
StringComparer.OrdinalIgnoreCase.Equals(element.Value, "bin\\");
|
||||
|
||||
if (!isValid) {
|
||||
string message = string.Format(
|
||||
"\"{0}\" element should be \"bin\\\" instead of \"{1}\".",
|
||||
element.Name.LocalName, element.Value);
|
||||
AddValidationError(element, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckProjectType(XDocument document) {
|
||||
var elements = document
|
||||
.Elements(Project)
|
||||
.Elements(PropertyGroup)
|
||||
.Elements(ProjectTypeGuids);
|
||||
foreach (var element in elements) {
|
||||
var guids = element.Value.Split(new char[] { ';' }).Select(g => Guid.Parse(g));
|
||||
|
||||
foreach (var guid in guids) {
|
||||
if (MvcGuids.Contains(guid)) {
|
||||
string message = string.Format(
|
||||
"\"{0}\" element contains an MVC tooling Guid. " +
|
||||
" This prevents the project from loading in Visual Studio if MVC tooling is not installed.",
|
||||
ProjectTypeGuids.LocalName);
|
||||
AddValidationError(element, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Error {
|
||||
public string Message { get; set; }
|
||||
public XElement XElement { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public int LineNumber { get; set; }
|
||||
public int ColumnNumber { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user