-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDependencyInjection.CodeAnalysis.csproj
More file actions
95 lines (84 loc) · 4.19 KB
/
DependencyInjection.CodeAnalysis.csproj
File metadata and controls
95 lines (84 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>Preview</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Devlooped.Extensions.DependencyInjection.CodeAnalysis</AssemblyName>
<PackFolder>analyzers/dotnet</PackFolder>
<IsRoslynComponent>true</IsRoslynComponent>
<DevelopmentDependency>true</DevelopmentDependency>
<DefineConstants>$(DefineConstants);DDI_ADDSERVICE;DDI_ADDSERVICES</DefineConstants>
<ImplicitUsings>false</ImplicitUsings>
<ILRepack>true</ILRepack>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGetizer" Version="1.4.6" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" Pack="false" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.3" />
<PackageReference Include="PolySharp" Version="1.15.0" PrivateAssets="all" />
<PackageReference Include="ThisAssembly.Resources" Version="2.1.2" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<None Update="Devlooped.Extensions.DependencyInjection.props" CopyToOutputDirectory="PreserveNewest" PackFolder="build\netstandard2.0" />
<None Update="Devlooped.Extensions.DependencyInjection.targets" CopyToOutputDirectory="PreserveNewest" PackFolder="build\netstandard2.0" />
<None Include="compile\*.cs" CopyToOutputDirectory="PreserveNewest" PackFolder="build\netstandard2.0" />
<ILRepackInclude Include="Microsoft.Bcl.HashCode" />
</ItemGroup>
<Target Name="PokePackageVersion" BeforeTargets="GetPackageContents" DependsOnTargets="CopyFilesToOutputDirectory;GetPackageVersion" Condition="'$(dotnet-nugetize)' == '' and Exists('$(OutputPath)\Devlooped.Extensions.DependencyInjection.props')">
<XmlPoke XmlInputPath="$(OutputPath)\Devlooped.Extensions.DependencyInjection.props" Query="/Project/PropertyGroup/DevloopedExtensionsDependencyInjectionVersion" Value="$(PackageVersion)" />
</Target>
<Import Project="..\ILRepack.targets" />
<UsingTask TaskName="XmlPoke" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Namespaces />
<Query />
<Value ParameterType="Microsoft.Build.Framework.ITaskItem" Required="true" />
<XmlInputPath ParameterType="Microsoft.Build.Framework.ITaskItem" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="System.Xml" />
<Using Namespace="System.Xml.Linq" />
<Using Namespace="System.Xml.XPath" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var xmlns = new XmlNamespaceManager(new NameTable());
if (!string.IsNullOrEmpty(Namespaces))
{
using (var reader = XmlReader.Create(new StringReader(Namespaces), new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Fragment }))
{
while (reader.Read())
{
var prefix = reader.GetAttribute("Prefix");
var uri = reader.GetAttribute("Uri");
xmlns.AddNamespace(prefix, uri);
}
}
}
var doc = XDocument.Load(XmlInputPath.GetMetadata("FullPath"), LoadOptions.PreserveWhitespace);
var expr = doc.CreateNavigator().Compile(Query);
expr.SetContext (xmlns);
var replacements = 0;
foreach (var node in doc.CreateNavigator().Select(expr).OfType<XPathNavigator>().Select(x => x.UnderlyingObject))
{
var attr = node as XAttribute;
var elem = node as XElement;
if (attr != null) {
attr.SetValue (Value.ItemSpec);
replacements++;
} else if (elem != null) {
elem.SetValue (Value.ItemSpec);
replacements++;
}
}
if (replacements != 0) {
Log.LogMessage ("Made {0} replacement(s).", replacements);
doc.Save(XmlInputPath.GetMetadata ("FullPath"), SaveOptions.DisableFormatting);
} else {
Log.LogMessage("No nodes were affected.");
}
]]>
</Code>
</Task>
</UsingTask>
</Project>