diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-02-13 11:56:14 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-02-13 11:56:14 -0800 |
commit | 6b1f72efa44b0d34c584a6551d07ab2160305aff (patch) | |
tree | 210b422d4be6e3473b3d7ab25e8a849477b025bb | |
parent | ace8234a246953b5af8b5856c2adaf9504488e94 (diff) | |
download | DotNetOpenAuth-6b1f72efa44b0d34c584a6551d07ab2160305aff.zip DotNetOpenAuth-6b1f72efa44b0d34c584a6551d07ab2160305aff.tar.gz DotNetOpenAuth-6b1f72efa44b0d34c584a6551d07ab2160305aff.tar.bz2 |
Almost finished getting basic project template layout working.
-rw-r--r-- | projecttemplates/projecttemplates.proj | 133 | ||||
-rw-r--r-- | src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs | 5 | ||||
-rw-r--r-- | src/DotNetOpenAuth.BuildTasks/MergeProjectWithVSTemplate.cs | 176 |
3 files changed, 155 insertions, 159 deletions
diff --git a/projecttemplates/projecttemplates.proj b/projecttemplates/projecttemplates.proj index 22b166b..a3fe94f 100644 --- a/projecttemplates/projecttemplates.proj +++ b/projecttemplates/projecttemplates.proj @@ -2,6 +2,7 @@ <Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/> <PropertyGroup> + <ProjectTemplateMaxPath Condition=" '$(ProjectTemplateMaxPath)' == '' ">50</ProjectTemplateMaxPath> <ProjectTemplatesLayoutPath>$(IntermediatePath)projecttemplates\</ProjectTemplatesLayoutPath> <ExtensionVsixLayoutDirectory>$(IntermediatePath)Vsix\</ExtensionVsixLayoutDirectory> @@ -9,6 +10,7 @@ BuildUnifiedProduct; ReSignDelaySignedAssemblies; DeploySql; + LayoutProjects; </LayoutDependsOn> <!-- We don't need to build the project templates, but to make sure we're not shipping junk, @@ -20,7 +22,7 @@ </PropertyGroup> <ItemGroup> - <ProjectTemplates Include="**\*.*proj" Exclude="$(MSBuildThisFileDirectory)$(MSBuildThisFile)" /> + <ProjectTemplates Include="**\*.*proj" Exclude="$(MSBuildThisFile)" /> </ItemGroup> <Target Name="Validate"> @@ -32,50 +34,17 @@ <MSBuild Projects="RelyingPartyDatabase\RelyingPartyDatabase.dbproj" Targets="Build;Deploy" BuildInParallel="$(BuildInParallel)" /> </Target> - <Target Name="Layout" DependsOnTargets="$(LayoutDependsOn)"> + <Target Name="LayoutProjects"> <ItemGroup> - <ProjectTemplatesSource Include="$(ProjectRoot)projecttemplates\**\*" - Exclude=" - $(ProjectRoot)projecttemplates\**\*.sln.cache; - $(ProjectRoot)projecttemplates\**\*.suo; - $(ProjectRoot)projecttemplates\**\*.gitignore; - $(ProjectRoot)projecttemplates\**\*.log*; - $(ProjectRoot)projecttemplates\**\*~; - $(ProjectRoot)projecttemplates\**\Settings.StyleCop; - $(ProjectRoot)projecttemplates\**\StyleCop.Cache; - $(ProjectRoot)projecttemplates\**\*.user; - $(ProjectRoot)projecttemplates\**\obj\**; - $(ProjectRoot)projecttemplates\**\bin\**; - $(ProjectRoot)projecttemplates\**\*.ldf; - $(ProjectRoot)projecttemplates\**\*.mdf; - $(ProjectRoot)projecttemplates\**\*.vsixmanifest; - "/> - <ProjectTemplatesSource Remove="@(ProjectTemplatesSource)" Condition=" '%(FullPath)' == '$(MSBuildThisFileDirectory)$(MSBuildThisFile)' " /> - <_ProjectTemplatesTransformSource Include="@(ProjectTemplatesSource)" Condition=" - '%(Extension)' == '.cs' - or '%(Extension)' == '.csproj' - or '%(Extension)' == '.sql' - or '%(Extension)' == '.config' - or '%(Extension)' == '.Master' - or '%(Extension)' == '.aspx' - or '%(Extension)' == '.ascx' - or '%(Extension)' == '.asax' - or '%(Extension)' == '.ashx' - "> - <BeforeTokens>%(RecursiveDir)</BeforeTokens> + <TemplateProjects Include="**\*.csproj" Exclude="$(MSBuildThisFile)"> <AfterTokens>$safeprojectname$</AfterTokens> <!-- Projects can get changed after the transform+copy operation, so don't skip copying them. --> - <SkipUnchangedFiles Condition="'%(Extension)' != '.csproj'">true</SkipUnchangedFiles> - <SkipUnchangedFiles Condition="'%(Extension)' == '.csproj'">false</SkipUnchangedFiles> - </_ProjectTemplatesTransformSource> - <ProjectTemplatesSource Remove="@(_ProjectTemplatesTransformSource)" /> - - <ProjectTemplatesLayout Include="@(ProjectTemplatesSource->'$(ProjectTemplatesLayoutPath)%(RecursiveDir)%(FileName)%(Extension)')"/> - <ProjectTemplatesTransformLayout Include="@(_ProjectTemplatesTransformSource->'$(ProjectTemplatesLayoutPath)%(RecursiveDir)%(FileName)%(Extension)')"/> - - <!-- Include the template icon --> - <ProjectTemplatesSource Include="$(ProjectRoot)doc\logo\favicon.ico" /> - <ProjectTemplatesLayout Include="$(ProjectTemplatesLayoutPath)__TemplateIcon.ico" /> + <SkipUnchangedFiles>false</SkipUnchangedFiles> + </TemplateProjects> + <TemplateProjects> + <BeforeTokens>%(RecursiveDir)</BeforeTokens> + </TemplateProjects> + <TemplateProjectsLayout Include="@(TemplateProjects->'$(ProjectTemplatesLayoutPath)%(RecursiveDir)%(FileName)%(Extension)')"/> <!-- Add external libraries --> <!-- Include the unified, signed version of the library --> @@ -88,50 +57,90 @@ <ProjectTemplateLibraries Include="$(ProjectRoot)lib\log4net.xml" /> <ProjectTemplateLibrariesTargets Include="@(ProjectTemplateLibraries->'$(ProjectTemplatesLayoutPath)RelyingPartyLogic\lib\%(FileName)%(Extension)')" /> - <ProjectTemplatesSource Include="@(ProjectTemplateLibraries)" /> - <ProjectTemplatesLayout Include="@(ProjectTemplateLibrariesTargets)" /> <FixupReferenceAssemblies Include="@(ProjectTemplateLibrariesTargets)" Condition="'%(Extension)' == '.dll'" /> - <InjectedLibraryItems Include="@(ProjectTemplateLibrariesTargets->'lib\%(FileName)%(Extension)')" /> - <VSProjectTemplates Include="@(ProjectTemplatesLayout)" Condition="'%(Extension)' == '.vstemplate'" /> + + <VSProjectTemplates Include="**\*.vstemplate" Exclude="*.vstemplate" /> + <VSProjectTemplatesLayout Include="@(VSProjectTemplates->'$(ProjectTemplatesLayoutPath)%(RecursiveDir)%(FileName)%(Extension)')" /> </ItemGroup> - <Trim Inputs="@(_ProjectTemplatesTransformSource)" MetadataName="BeforeTokens" AllAfter="\"> - <Output TaskParameter="Outputs" ItemName="ProjectTemplatesTransformSource" /> + <Trim Inputs="@(TemplateProjects)" MetadataName="BeforeTokens" AllAfter="\"> + <Output TaskParameter="Outputs" ItemName="TemplateProjectsTransformSource" /> </Trim> - <!--<MSBuild Projects="@(ProjectTemplates)" />--> - <Copy SourceFiles="@(ProjectTemplatesSource)" DestinationFiles="@(ProjectTemplatesLayout)" SkipUnchangedFiles="true" /> - <CopyWithTokenSubstitution SourceFiles="@(ProjectTemplatesTransformSource)" DestinationFiles="@(ProjectTemplatesTransformLayout)"> - <Output TaskParameter="CopiedFiles" ItemName="CopiedProjectTemplateFiles" /> + <CopyWithTokenSubstitution SourceFiles="@(TemplateProjectsTransformSource)" DestinationFiles="@(TemplateProjectsLayout)"> + <Output TaskParameter="CopiedFiles" ItemName="CopiedProjectFiles" /> </CopyWithTokenSubstitution> <ChangeProjectReferenceToAssemblyReference - Projects="@(CopiedProjectTemplateFiles)" - Condition="'%(Extension)' == '.csproj'" + Projects="@(CopiedProjectFiles)" + Condition=" '%(Extension)' == '.csproj' " ProjectReference="..\..\src\$(ProductName)\$(ProductName).csproj" Reference="Lib\$(ProductName).dll" /> <FixupReferenceHintPaths - Projects="@(CopiedProjectTemplateFiles)" - Condition="'%(CopiedProjectTemplateFiles.Extension)' == '.csproj'" + Projects="@(CopiedProjectFiles)" References="@(FixupReferenceAssemblies)" /> <AddProjectItems - Projects="@(CopiedProjectTemplateFiles)" - Condition="'%(CopiedProjectTemplateFiles.FileName)%(CopiedProjectTemplateFiles.Extension)' == 'RelyingPartyLogic.csproj'" + Projects="@(CopiedProjectFiles)" + Condition="'%(CopiedProjectFiles.FileName)%(CopiedProjectFiles.Extension)' == 'RelyingPartyLogic.csproj'" Items="@(InjectedLibraryItems)" /> <MergeProjectWithVSTemplate ProjectItemTypes="@(VsTemplateProjectItemTypes)" ReplaceParametersExtensions="@(VsTemplateParameterReplaceExtensions)" - Templates="@(VSProjectTemplates)" + SourceTemplates="@(VSProjectTemplates)" + SourceProjects="@(TemplateProjectsLayout)" + DestinationTemplates="@(VSProjectTemplatesLayout)" + MaximumRelativePathLength="$(ProjectTemplateMaxPath)" > - <Output TaskParameter="MaxPathAdjustedPaths" ItemName="ProjectItemShortPathAdjustments"/> + <Output TaskParameter="ProjectItems" ItemName="TemplateProjectItems"/> </MergeProjectWithVSTemplate> + </Target> + + <Target Name="Layout" DependsOnTargets="$(LayoutDependsOn)"> + <ItemGroup> + <TemplateProjectItems Condition=" + '%(Extension)' == '.cs' + or '%(Extension)' == '.csproj' + or '%(Extension)' == '.sql' + or '%(Extension)' == '.config' + or '%(Extension)' == '.Master' + or '%(Extension)' == '.aspx' + or '%(Extension)' == '.ascx' + or '%(Extension)' == '.asax' + or '%(Extension)' == '.ashx' + "> + <BeforeTokens>%(RecursiveDir)</BeforeTokens> + <AfterTokens>$safeprojectname$</AfterTokens> + </TemplateProjectItems> + <TemplateProjectItems> + <SkipUnchangedFiles>true</SkipUnchangedFiles> + </TemplateProjectItems> + <TemplateProjectItemsForTransformSource Include="@(TemplateProjectItems->'%(SourceFullPath)')" /> + <TemplateProjectItemsForTransformLayout Include="@(TemplateProjectItems->'%(DestinationFullPath)')" /> + + <RootVsTemplateSource Include="*.vstemplate" /> + <ProjectTemplatesSource Include="@(RootVsTemplateSource)" /> + <ProjectTemplatesLayout Include="@(RootVsTemplateSource->'$(ProjectTemplatesLayoutPath)%(FileName)%(Extension)')" /> + + <!-- Include the template icon --> + <ProjectTemplatesSource Include="$(ProjectRoot)doc\logo\favicon.ico" /> + <ProjectTemplatesLayout Include="$(ProjectTemplatesLayoutPath)__TemplateIcon.ico" /> + </ItemGroup> + + <Copy + SourceFiles="@(ProjectTemplatesSource)" + DestinationFiles="@(ProjectTemplatesLayout)" + SkipUnchangedFiles="true" /> + <CopyWithTokenSubstitution + SourceFiles="@(TemplateProjectItemsForTransformSource)" + DestinationFiles="@(TemplateProjectItemsForTransformLayout)" /> <ItemGroup> <ProjectTemplateIntendedFiles Include=" @(ProjectTemplatesLayout); - @(ProjectTemplatesTransformLayout); - %(ProjectItemShortPathAdjustments.ShortPath); + @(TemplateProjectItemsForTransformLayout); + @(VSProjectTemplatesLayout); + @(TemplateProjectsLayout); " /> <ProjectTemplateIntendedFiles Remove="@(ProjectItemShortPathAdjustments)" /> </ItemGroup> diff --git a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs index e973962..5b097ab 100644 --- a/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs +++ b/src/DotNetOpenAuth.BuildTasks/CopyWithTokenSubstitution.cs @@ -56,7 +56,8 @@ namespace DotNetOpenAuth.BuildTasks { for (int i = 0; i < this.SourceFiles.Length; i++) { string sourcePath = this.SourceFiles[i].ItemSpec; string destPath = this.DestinationFiles[i].ItemSpec; - bool skipUnchangedFiles = bool.Parse(this.SourceFiles[i].GetMetadata("SkipUnchangedFiles")); + bool skipUnchangedFiles; + bool.TryParse(this.SourceFiles[i].GetMetadata("SkipUnchangedFiles"), out skipUnchangedFiles); if (!Directory.Exists(Path.GetDirectoryName(destPath))) { Directory.CreateDirectory(Path.GetDirectoryName(destPath)); @@ -69,7 +70,7 @@ namespace DotNetOpenAuth.BuildTasks { continue; } - Log.LogMessage(MessageImportance.Normal, "Copying \"{0}\" -> \"{1}\"", sourcePath, destPath); + Log.LogMessage(MessageImportance.Normal, "Copying file from \"{0}\" to \"{1}\"", sourcePath, destPath); File.Copy(sourcePath, destPath, true); } else { // We deliberably consider newer destination files to be up-to-date rather than diff --git a/src/DotNetOpenAuth.BuildTasks/MergeProjectWithVSTemplate.cs b/src/DotNetOpenAuth.BuildTasks/MergeProjectWithVSTemplate.cs index f166e63..601ff6f 100644 --- a/src/DotNetOpenAuth.BuildTasks/MergeProjectWithVSTemplate.cs +++ b/src/DotNetOpenAuth.BuildTasks/MergeProjectWithVSTemplate.cs @@ -34,41 +34,42 @@ namespace DotNetOpenAuth.BuildTasks { public string[] ReplaceParametersExtensions { get; set; } [Required] - public ITaskItem[] Templates { get; set; } + public ITaskItem[] SourceTemplates { get; set; } - /// <summary> - /// Gets or sets the path to the .vsixmanifest file that will be used to assist - /// in calculating the actual full path of project items. - /// </summary> - /// <remarks> - /// This property is required if <see cref="EnsureMaxPath"/> > 0; - /// </remarks> - public ITaskItem VsixManifest { get; set; } + [Required] + public ITaskItem[] SourceProjects { get; set; } + + [Required] + public ITaskItem[] DestinationTemplates { get; set; } /// <summary> /// Gets or sets the maximum length a project item's relative path should /// be limited to, artificially renaming them as necessary. /// </summary> /// <value>Use 0 to disable the renaming feature.</value> - public int EnsureMaxPath { get; set; } + public int MaximumRelativePathLength { get; set; } /// <summary> - /// Gets or sets the project items that had to be renamed to comply with maximum path length requirements. + /// Gets or sets the project item paths from the source project to copy to the destination location. /// </summary> - /// <remarks> - /// The item name is the original full path. The ShortPath metadata contains the shortened full path. - /// </remarks> [Output] - public ITaskItem[] MaxPathAdjustedPaths { get; set; } + public ITaskItem[] ProjectItems { get; set; } /// <summary> /// Executes this instance. /// </summary> public override bool Execute() { - var shortenedItems = new List<ITaskItem>(); - int uniqueItemCounter = 0; + if (this.DestinationTemplates.Length != this.SourceTemplates.Length) { + this.Log.LogError("SourceTemplates array has length {0} while DestinationTemplates array has length {1}, but must equal.", this.SourceTemplates.Length, this.DestinationTemplates.Length); + } + if (this.SourceProjects.Length != this.SourceTemplates.Length) { + this.Log.LogError("SourceTemplates array has length {0} while SourceProjects array has length {1}, but must equal.", this.SourceTemplates.Length, this.SourceProjects.Length); + } + + var projectItemsToCopy = new List<ITaskItem>(); - foreach (ITaskItem sourceTemplateTaskItem in this.Templates) { + for (int iTemplate = 0; iTemplate < this.SourceTemplates.Length; iTemplate++) { + ITaskItem sourceTemplateTaskItem = this.SourceTemplates[iTemplate]; var template = XElement.Load(sourceTemplateTaskItem.ItemSpec); var templateContentElement = template.Element(XName.Get("TemplateContent", VSTemplateNamespace)); var projectElement = templateContentElement.Element(XName.Get("Project", VSTemplateNamespace)); @@ -77,24 +78,69 @@ namespace DotNetOpenAuth.BuildTasks { continue; } - var projectPath = Path.Combine(Path.GetDirectoryName(sourceTemplateTaskItem.ItemSpec), projectElement.Attribute("File").Value); + var projectPath = this.SourceProjects[iTemplate].ItemSpec; var projectDirectory = Path.GetDirectoryName(Path.Combine(Path.GetDirectoryName(sourceTemplateTaskItem.GetMetadata("FullPath")), projectElement.Attribute("File").Value)); Log.LogMessage("Merging project \"{0}\" with \"{1}\".", projectPath, sourceTemplateTaskItem.ItemSpec); var sourceProject = new Project(); sourceProject.Load(projectPath); + var projectItems = sourceProject.EvaluatedItems.Cast<BuildItem>().Where(item => this.ProjectItemTypes.Contains(item.Name)); + + // Figure out where every project item is in source, and where it will go in the destination, + // taking into account a given maximum path length that may require that we shorten the path. + var sourceToDestinationProjectItemMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + //var oversizedItemPaths = projectItems.Where(item => item.Include.Length > this.MaximumRelativePathLength); + foreach (var item in projectItems) { + var source = item.Include; + var dest = item.Include; + + // if (this.MaximumRelativePathLength > 0) { + // if (item.Include.Length > this.MaximumRelativePathLength) { + // string leafName = Path.GetFileName(item.Include); + // int targetLeafLength = leafName.Length - (item.Include.Length - this.MaximumRelativePathLength); + // string shortenedFileName = CreateUniqueShortFileName(leafName, targetLeafLength); + // string shortenedRelativePath = Path.Combine(Path.GetDirectoryName(item.Include), shortenedFileName); + // if (shortenedRelativePath.Length <= this.MaximumRelativePathLength) { + // this.Log.LogMessage( + // "Renaming long project item '{0}' to '{1}' within project template to avoid MAX_PATH issues. The instantiated project will remain unchanged.", + // item.Include, + // shortenedRelativePath); + // projectItem.SetAttributeValue("TargetFileName", Path.GetFileName(item.Include)); + // projectItem.Value = shortenedFileName; + // string originalFullPath = Path.Combine(projectDirectory, item.Include); + // string shortenedFullPath = Path.Combine(projectDirectory, shortenedRelativePath); + // if (File.Exists(shortenedFullPath)) { + // File.Delete(shortenedFullPath); // File.Move can't overwrite files + // } + // File.Move(originalFullPath, shortenedFullPath); + + // // Document the change so the build system can account for it. + // TaskItem shortChange = new TaskItem(originalFullPath); + // shortChange.SetMetadata("ShortPath", shortenedFullPath); + // shortenedItems.Add(shortChange); + // } else { + // this.Log.LogError( + // "Project item '{0}' exceeds maximum allowable length {1} by {2} characters and it cannot be sufficiently shortened. Estimated full path is: '{3}'.", + // item.Include, + // this.MaximumRelativePathLength, + // item.Include.Length - this.MaximumRelativePathLength, + // item.Include); + // } + // } + //} + + sourceToDestinationProjectItemMap[source] = dest; + } // Collect the project items from the project that are appropriate // to include in the .vstemplate file. - var itemsByFolder = from item in sourceProject.EvaluatedItems.Cast<BuildItem>() - where this.ProjectItemTypes.Contains(item.Name) + var itemsByFolder = from item in projectItems orderby item.Include group item by Path.GetDirectoryName(item.Include); + foreach (var folder in itemsByFolder) { XElement parentNode = projectElement; - if (folder.Key.Length > 0) { - parentNode = FindOrCreateParent((uniqueItemCounter++).ToString("x"), projectElement); - parentNode.SetAttributeValue("TargetFolderName", folder.Key); - } + parentNode = FindOrCreateParent(folder.Key, projectElement); + //parentNode.SetAttributeValue("TargetFolderName", folder.Key); foreach (var item in folder) { bool replaceParameters = this.ReplaceParametersExtensions.Contains(Path.GetExtension(item.Include)); @@ -107,50 +153,21 @@ namespace DotNetOpenAuth.BuildTasks { if (replaceParameters) { projectItem.SetAttributeValue("ReplaceParameters", "true"); } - - if (this.EnsureMaxPath > 0) { - string estimatedFullPath = EstimateFullPathInProjectCache(Path.GetFileNameWithoutExtension(sourceProject.FullFileName), item.Include); - if (estimatedFullPath.Length > this.EnsureMaxPath) { - string leafName = Path.GetFileName(item.Include); - int targetLeafLength = leafName.Length - (estimatedFullPath.Length - this.EnsureMaxPath); - string shortenedFileName = CreateUniqueShortFileName(leafName, targetLeafLength); - string shortenedRelativePath = Path.Combine(Path.GetDirectoryName(item.Include), shortenedFileName); - string shortenedEstimatedFullPath = EstimateFullPathInProjectCache(Path.GetFileNameWithoutExtension(sourceProject.FullFileName), shortenedRelativePath); - if (shortenedEstimatedFullPath.Length <= this.EnsureMaxPath) { - this.Log.LogMessage( - "Renaming long project item '{0}' to '{1}' within project template to avoid MAX_PATH issues. The instantiated project will remain unchanged.", - item.Include, - shortenedRelativePath); - projectItem.SetAttributeValue("TargetFileName", Path.GetFileName(item.Include)); - projectItem.Value = shortenedFileName; - string originalFullPath = Path.Combine(projectDirectory, item.Include); - string shortenedFullPath = Path.Combine(projectDirectory, shortenedRelativePath); - if (File.Exists(shortenedFullPath)) { - File.Delete(shortenedFullPath); // File.Move can't overwrite files - } - File.Move(originalFullPath, shortenedFullPath); - - // Document the change so the build system can account for it. - TaskItem shortChange = new TaskItem(originalFullPath); - shortChange.SetMetadata("ShortPath", shortenedFullPath); - shortenedItems.Add(shortChange); - } else { - this.Log.LogError( - "Project item '{0}' exceeds maximum allowable length {1} by {2} characters and it cannot be sufficiently shortened. Estimated full path is: '{3}'.", - item.Include, - this.EnsureMaxPath, - estimatedFullPath.Length - this.EnsureMaxPath, - estimatedFullPath); - } - } - } } } - template.Save(sourceTemplateTaskItem.ItemSpec); + template.Save(this.DestinationTemplates[iTemplate].ItemSpec); + foreach (var pair in sourceToDestinationProjectItemMap) { + TaskItem item = new TaskItem(Path.Combine(Path.GetDirectoryName(this.SourceTemplates[iTemplate].ItemSpec), pair.Key)); + item.SetMetadata("SourceFullPath", Path.GetFullPath(Path.Combine(Path.GetDirectoryName(this.SourceTemplates[iTemplate].ItemSpec), pair.Key))); + item.SetMetadata("DestinationFullPath", Path.GetFullPath(Path.Combine(Path.GetDirectoryName(this.DestinationTemplates[iTemplate].ItemSpec), pair.Value))); + item.SetMetadata("RecursiveDir", Path.GetDirectoryName(this.SourceTemplates[iTemplate].ItemSpec)); + projectItemsToCopy.Add(item); + } } - this.MaxPathAdjustedPaths = shortenedItems.ToArray(); + this.ProjectItems = projectItemsToCopy.ToArray(); + return !Log.HasLoggedErrors; } @@ -199,36 +216,5 @@ namespace DotNetOpenAuth.BuildTasks { return parent; } - - private string EstimateFullPathInProjectCache(string projectName, string itemRelativePath) { - Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(projectName)); - Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(itemRelativePath)); - - const string PathRoot = @"c:\documents and settings\usernameZZZ\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\"; - string subPath; - if (!vsixContributionToPath.TryGetValue(projectName, out subPath)) { - if (this.VsixManifest == null) { - this.Log.LogError("The task parameter VsixManifests is required but missing."); - } - var vsixDocument = XDocument.Load(this.VsixManifest.ItemSpec); - XElement vsix = vsixDocument.Element(XName.Get("Vsix", VsixNamespace)); - XElement identifier = vsix.Element(XName.Get("Identifier", VsixNamespace)); - XElement content = vsix.Element(XName.Get("Content", VsixNamespace)); - string author = identifier.Element(XName.Get("Author", VsixNamespace)).Value; - string name = identifier.Element(XName.Get("Name", VsixNamespace)).Value; - string version = identifier.Element(XName.Get("Version", VsixNamespace)).Value; - string pt = content.Element(XName.Get("ProjectTemplate", VsixNamespace)).Value; - vsixContributionToPath[projectName] = subPath = string.Format( - CultureInfo.InvariantCulture, - @"{0}\{1}\{2}\~PC\{3}\CSharp\Web\{4}.zip\", - author, - name, - version, - pt, - projectName - ); - } - return Path.Combine(PathRoot + subPath + Path.GetFileNameWithoutExtension(projectName), itemRelativePath); - } } } |