This repository has been archived by the owner on Feb 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
NuGetProvider.csproj
218 lines (200 loc) · 12.1 KB
/
NuGetProvider.csproj
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Condition="Exists( '$(MSBuildThisFileDirectory)packages\Outercurve.MSBuildTasks.1.0.0.1\build\Outercurve.MSBuildTasks.tasks' )" Project="$(MSBuildThisFileDirectory)packages\Outercurve.MSBuildTasks.1.0.0.1\build\Outercurve.MSBuildTasks.tasks" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<PSVersion>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine@PowerShellVersion)</PSVersion>
<!--
If you have PowerShell 5.0 or greater installed, you must compile this with .NET 4.5 or higher
otherwise, we'll assume .Net 4.0 for the assemblies.
-->
<TargetFrameworkVersion Condition="($(PSVersion.Substring(0,1)) > 4) AND ($(TargetFrameworkVersion) == '' Or $(TargetFrameworkVersion) == '*Undefined*')">v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion Condition="($(PSVersion.Substring(0,1)) < 5) AND ($(TargetFrameworkVersion) == '' Or $(TargetFrameworkVersion) == '*Undefined*')">v4.0</TargetFrameworkVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6EE48B32-D449-47A5-B69F-B2D8E9BAD867}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.PackageManagement.NuGetProvider</RootNamespace>
<AssemblyName>Microsoft.PackageManagement.NuGetProvider</AssemblyName>
<FileAlignment>512</FileAlignment>
<!-- Community Build Settings -->
<OutputPath>$(MSBuildThisFileDirectory)output\$(TargetFrameworkVersion.Replace(".",""))\$(Configuration)\bin\</OutputPath>
<SignedDir>$(MSBuildThisFileDirectory)output\$(TargetFrameworkVersion.Replace(".",""))\$(Configuration)\Signed\</SignedDir>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)intermediate\$(TargetFrameworkVersion.Replace(".",""))\$(Configuration)\$(AssemblyName)\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
<DocumentationFile>$(OutputPath)$(AssemblyName).XML</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
<NoWarn>1591,3002,3003,3008,3009</NoWarn>
<RestorePackages>true</RestorePackages>
<DefineConstants>FRAMEWORK$(TargetFrameworkVersion.Replace(".",""))</DefineConstants>
<OutputRelativePath>output\$(TargetFrameworkVersion.Replace(".",""))\$(Configuration)\bin\</OutputRelativePath>
<StartAction>Program</StartAction>
<StartProgram>c:\windows\system32\windowspowerShell\v1.0\powershell.exe</StartProgram>
<StartArguments>-noexit %24debugPreference = %27Continue%27 %3b get-packageprovider -verbose</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nuget, Version=2.8.50926.602, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>libs\nuget.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="assembly-version.cs" />
<Compile Include="Common\AsyncProcess.cs" />
<Compile Include="NuGetProvider.cs" />
<Compile Include="Common\EnvironmentUtility.cs" />
<Compile Include="Common\Extensions.cs" />
<Compile Include="Common\ImplictLazy.cs" />
<Compile Include="Common\MutableEnumerable.cs" />
<Compile Include="Common\NativeMethods.cs" />
<Compile Include="Common\PackageItem.cs" />
<Compile Include="Common\PackageSource.cs" />
<Compile Include="NuGetRequest.cs" />
<Compile Include="Common\ReEnumerable.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\Messages.Designer.cs" />
<Compile Include="Sdk\Constants.cs" />
<Compile Include="Sdk\ErrorCategory.cs" />
<Compile Include="Sdk\Request.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Messages.resx" />
</ItemGroup>
<ItemGroup>
<None Include="provider.manifest" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<BeforeBuildScript>
# remove old merged file.
erase -force -ea silentlycontinue "$(TargetDir)nuget-anycpu-*.exe"
# make sure the signed output folder is created
rmdir -force -recurse -ea silentlycontinue "$(SignedDir)"
mkdir -force -ea silentlycontinue "$(SignedDir)"
if ( $env:APPVEYOR_BUILD_VERSION ) {
$v = $env:APPVEYOR_BUILD_VERSION
$filepath = resolve-path "$(MSBuildThisFileDirectory)\assembly-version.cs"
$content = (get-content -raw $filepath )
$content = $content -replace "assembly: AssemblyVersion.*","assembly: AssemblyVersion(`"$v`")]"
$content = $content -replace "assembly: AssemblyFileVersion.*","assembly: AssemblyFileVersion(`"$v`")]"
set-content $filepath $content
$filepath = resolve-path "$(MSBuildThisFileDirectory)\provider.manifest"
$content = (get-content -raw $filepath )
$content = $content -replace "\s+version='.*'"," version='$v'"
$content = $content -replace "uniqueId='.*'","uniqueId='nuget.$v'"
$content = $content -replace "providerVersion='.*'","providerVersion='$v'"
$content = $content -replace "href='.*'","href='https://oneget.org/nuget-anycpu-$v.exe'"
set-content $filepath $content
}
# unregister any previously compiled assembly
mkdir hkcu:software\Microsoft\PackageManagement -ea silentlycontinue
Set-ItemProperty -Path hkcu:software\Microsoft\PackageManagement -Name NuGet -Value $null
</BeforeBuildScript>
<AfterBuildScript><![CDATA[
# Find the manifest tool, sometimes it's not in the PATH
$MTEXE = ((Get-ItemProperty -Path HKCU:\Software\PackageManagement\Tools\MT.EXE -Name Path -ea 0).Path)
if( -not $MTEXE ) {
$MTEXE = ((dir ${env:ProgramFiles(x86)} -recurse -ea 0| where -property name -eq mt.exe | select -first 1 ).FullName)
$null = mkdir -Path HKCU:\Software\PackageManagement\Tools\MT.EXE -Force
$null = New-ItemProperty -Path HKCU:\Software\PackageManagement\Tools\MT.EXE -Name Path -Value $MTEXE -force
}
# get the version of the file we just built
$file = resolve-path "$(TargetDir)Microsoft.PackageManagement.NuGetProvider.dll"
$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo( $file ).fileversion
# update the manifest to the right version.
$manifestfile = resolve-path "$(MSBuildThisFileDirectory)\provider.manifest"
$newver = "version='$version'"
$newContent = (get-content -raw $manifestfile ) -replace "version='.*'",$newver
$newContent = $newContent -replace "providerversion","providerVersion"
$newContent = $newContent.Trim();
set-content $manifestfile $newcontent
# Run the manifest tool to add the Swidtag Manifest onto the assembly
# (this allows oneget to use it as a provider!)
$null = & "$MTEXE" -manifest "$manifestfile" "-outputresource:$(TargetPath);#101"
# register the assembly for use by OneGet by sticking in a registry key.
mkdir hkcu:software\Microsoft\PackageManagement -ea silentlycontinue
Set-ItemProperty -Path hkcu:software\Microsoft\PackageManagement -Name NuGet -Value "$(TargetPath)"
if( "$(Configuration)" -eq "Release" ) {
$frameworkPath = "${env:programfiles(x86)}\Reference Assemblies\Microsoft\Framework\.NetFramework\v4.0"
if( -not (test-path $frameworkPath )) {
throw "can't find framework path at $frameworkPath "
}
#we need a copy of sma.dll
$null = copy "C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll" $(TargetDir)
$outputFile = "$(TargetDir)nuget-anycpu-$version.exe"
#merge the assemblies
$null = echo "Merging assemblies into single release assembly"
$null = .\tools\ILMerge.exe /targetplatform:"v4,$frameworkPath" /out:$outputFile /log:.\ilrepack.log /allowDup /ver:$version /attr:$(TargetDir)Microsoft.PackageManagement.NuGetProvider.dll $(TargetDir)nuget.exe $(TargetDir)Microsoft.PackageManagement.NuGetProvider.dll
if( test-path $outputFile ) {
copy (resolve-path "$(MSBuildThisFileDirectory)\provider.manifest") "$(SignedDir)nuget-$version.package.swidtag"
return $outputFile
}
return $null
}
]]></AfterBuildScript>
</PropertyGroup>
<Target Name="BeforeBuild">
<PowerShell ScriptBlock="$(BeforeBuildScript)" />
</Target>
<Target Name="AfterBuild">
<PowerShell ScriptBlock="$(AfterBuildScript)">
<Output PropertyName="outputFile" TaskParameter="Outputs" />
</PowerShell>
<SetSignature Condition="'$(OUTERCURVE_TOKEN)' != '' AND '$(outputFile)' != '' " InputFiles="$(outputFile)" OutputDir="$(SignedDir)" StrongName="false" ContinueOnError="false" ServiceUrl="http://api.outercurve.org" UserName="gserack" Password="$(OUTERCURVE_TOKEN)" />
</Target>
<UsingTask TaskName="PowerShell" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<ScriptBlock ParameterType="System.String" Required="true" />
<Inputs ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<Outputs ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Management.Automation" />
<Using Namespace="System" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Management.Automation" />
<Using Namespace="System.Management.Automation.Runspaces" />
<Using Namespace="System.Text" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs"><![CDATA[
var ps = System.Management.Automation.PowerShell.Create();
ps.AddScript( ScriptBlock );
List<ITaskItem> outs = new List<ITaskItem>();
foreach( var i in ((IEnumerable<object>)ps.Invoke((Inputs ?? new ITaskItem[0]).Where( each => each != null ).Select( each => each.ToString() ))).Where( each => each != null ).Select( each => new TaskItem( each.ToString() )) ) {
outs.Add( i );
Console.WriteLine( i.ToString() );
}
Outputs = outs.ToArray();
]]></Code>
</Task>
</UsingTask>
</Project>