Skip to content
This repository was archived by the owner on Mar 20, 2019. It is now read-only.

Commit bbac993

Browse files
committed
Fixed up project references in samples and project templates.
1 parent 9c24bec commit bbac993

6 files changed

Lines changed: 28 additions & 15 deletions

File tree

lib/DotNetOpenAuth.BuildTasks.dll

1 KB
Binary file not shown.

lib/DotNetOpenAuth.BuildTasks.pdb

0 Bytes
Binary file not shown.

projecttemplates/projecttemplates.proj

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
$(LayoutDependsOn);
2121
</LayoutDependsOn>
2222
</PropertyGroup>
23-
23+
2424
<ItemGroup>
2525
<ProjectTemplates Include="**\*.*proj" Exclude="$(MSBuildThisFile)" />
26+
27+
<ProjectReferencesToRemove Include="..\RelyingPartyDatabase\RelyingPartyDatabase.dbproj"/>
28+
<AssemblyReferencesToReplaceWith Include="REMOVE" />
2629
</ItemGroup>
2730

2831
<Target Name="Validate">
@@ -85,9 +88,9 @@
8588
</CopyWithTokenSubstitution>
8689
<ChangeProjectReferenceToAssemblyReference
8790
Projects="@(CopiedProjectFiles)"
88-
Condition=" '%(Extension)' == '.csproj' "
89-
ProjectReferences="..\..\src\$(ProductName)\$(ProductName).csproj;..\RelyingPartyDatabase\RelyingPartyDatabase.dbproj"
90-
References="Lib\$(ProductName).dll;REMOVE" />
91+
Condition=" '%(CopiedProjectFiles.Extension)' == '.csproj' "
92+
ProjectReferences="@(ProjectReferencesToRemove)"
93+
References="@(AssemblyReferencesToReplaceWith)" />
9194
<FixupReferenceHintPaths
9295
Projects="@(CopiedProjectFiles)"
9396
References="@(FixupReferenceAssemblies)"
@@ -133,12 +136,12 @@
133136
<VS2010ProjectTemplateZipFiles Include="@(TopLevelVS2010ProjectTemplates->'%(RootDir)%(Directory)%(FileName).zip')" />
134137
</ItemGroup>
135138

136-
<Copy
137-
SourceFiles="@(ProjectTemplatesSource)"
138-
DestinationFiles="@(ProjectTemplatesLayout)"
139+
<Copy
140+
SourceFiles="@(ProjectTemplatesSource)"
141+
DestinationFiles="@(ProjectTemplatesLayout)"
139142
SkipUnchangedFiles="true" />
140-
<CopyWithTokenSubstitution
141-
SourceFiles="@(TemplateProjectItemsForTransformSource)"
143+
<CopyWithTokenSubstitution
144+
SourceFiles="@(TemplateProjectItemsForTransformSource)"
142145
DestinationFiles="@(TemplateProjectItemsForTransformLayout)" />
143146

144147
<ItemGroup>
@@ -190,7 +193,7 @@
190193
ZipLevel="$(ZipLevel)"
191194
/>
192195
</Target>
193-
196+
194197
<Target Name="Layout2008" DependsOnTargets="Layout">
195198
<ItemGroup>
196199
<ProjectTemplates2008Source Include="$(ProjectTemplatesLayoutPath)**" Exclude="$(ProjectTemplatesLayoutPath)*.zip" />
@@ -214,7 +217,7 @@
214217
InPlaceDowngrade="true"
215218
/>
216219

217-
<Purge Directories="$(ProjectTemplates2008LayoutPath)"
220+
<Purge Directories="$(ProjectTemplates2008LayoutPath)"
218221
IntendedFiles="@(ProjectTemplates2008Layout);@(VS2008ProjectTemplateZipFiles)" />
219222
</Target>
220223

src/DotNetOpenAuth.BuildTasks/ChangeProjectReferenceToAssemblyReference.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ public class ChangeProjectReferenceToAssemblyReference : Task {
2626
public ITaskItem[] ProjectReferences { get; set; }
2727

2828
/// <summary>
29-
/// The assembly references to add.
29+
/// The assembly references to replace removed project references with.
3030
/// </summary>
3131
[Required]
3232
public ITaskItem[] References { get; set; }
3333

3434
public override bool Execute() {
3535
if (this.ProjectReferences.Length != this.References.Length) {
3636
this.Log.LogError("ProjectReferences and References arrays do not have matching lengths.");
37+
this.Log.LogError("ProjectReferences contents ({0} elements): {1}", this.ProjectReferences.Length, String.Join<ITaskItem>(";", this.ProjectReferences));
38+
this.Log.LogError("References contents ({0} elements): {1}", this.References.Length, String.Join<ITaskItem>(";", this.References));
39+
return false;
3740
}
3841

3942
foreach (var project in Projects) {
@@ -50,8 +53,12 @@ join refToRemove in this.ProjectReferences on reference.Include equals refToRemo
5053
doc.RemoveItem(matchingReference.Remove);
5154
if (matchingReference.Add.ItemSpec != "REMOVE") {
5255
this.Log.LogMessage("Adding assembly reference to \"{0}\" to \"{1}\".", matchingReference.Add.ItemSpec, project.ItemSpec);
53-
var newReference = doc.AddNewItem("Reference", Path.GetFileNameWithoutExtension(matchingReference.Add.ItemSpec), true);
54-
newReference.SetMetadata("HintPath", matchingReference.Add.ItemSpec);
56+
57+
string newItemSpec = Path.GetFileNameWithoutExtension(matchingReference.Add.ItemSpec);
58+
if (!doc.GetEvaluatedItemsByName("Reference").OfType<BuildItem>().Any(bi => String.Equals(bi.Include, newItemSpec, StringComparison.OrdinalIgnoreCase))) {
59+
var newReference = doc.AddNewItem("Reference", newItemSpec, true);
60+
newReference.SetMetadata("HintPath", matchingReference.Add.ItemSpec);
61+
}
5562
}
5663
}
5764

tools/DotNetOpenAuth.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
" />
6565
<ProductProjects Include="@(ProductProjectNames->'$(ProjectRoot)src\%(Identity)\%(Identity).csproj')"/>
6666

67+
<ProjectReferencesToRemove Include="@(ProductProjectNames->'..\..\src\%(Identity)\%(Identity).csproj')" />
68+
<AssemblyReferencesToReplaceWith Include="@(ProjectReferencesToRemove->'..\..\Bin\$(ProductName).dll')" />
69+
6770
<SignDependsOn Include="Build" Condition=" '$(SuppressBuildTarget)' != 'true' " />
6871
<ILMergeInputAssemblies Condition=" '$(ClrVersion)' == '2' "
6972
Include="$(ProjectRoot)lib\Microsoft.Contracts.dll" />

tools/drop.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
RemoveImportsStartingWith="%24(ProjectRoot)tools\"
138138
AddReferences="Microsoft.Contracts"/>
139139
<ChangeProjectReferenceToAssemblyReference Projects="@(SampleProjectTargets)"
140-
ProjectReferences="..\..\src\$(ProductName)\$(ProductName).csproj" References="..\..\Bin\$(ProductName).dll" />
140+
ProjectReferences="@(ProjectReferencesToRemove)" References="@(AssemblyReferencesToReplaceWith)" />
141141
<DowngradeProjects
142142
Projects="@(SampleProjectTargets);@(SampleSolutionTargets)"
143143
DowngradeMvc2ToMvc1="$(DowngradeMvc2ToMvc1)"

0 commit comments

Comments
 (0)