|
| 1 | +<Projectxmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 2 | +<!-- Prevent dotnet template engine to parse this file--> |
| 3 | +<!--/-:cnd:noEmit--> |
| 4 | + <PropertyGroup> |
| 5 | +<!-- make MSBuild track this file for incremental builds.--> |
| 6 | +<!-- ref https://blogs.msdn.microsoft.com/msbuild/2005/09/26/how-to-ensure-changes-to-a-custom-target-file-prompt-a-rebuild/--> |
| 7 | + <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> |
| 8 | +<!-- Mark that this target file has been loaded.--> |
| 9 | + <IsPaketRestoreTargetsFileLoaded>true</IsPaketRestoreTargetsFileLoaded> |
| 10 | + <PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath> |
| 11 | + <PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath> |
| 12 | + <PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile> |
| 13 | + <PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath> |
| 14 | + <MonoPathCondition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath> |
| 15 | + <MonoPathCondition="'$(MonoPath)' == ''">mono</MonoPath> |
| 16 | +<!-- Paket command--> |
| 17 | + <PaketExePathCondition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath> |
| 18 | + <PaketExePathCondition=" '$(PaketExePath)' == ''">$(PaketToolsPath)paket.exe</PaketExePath> |
| 19 | + <PaketCommandCondition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand> |
| 20 | + <PaketCommandCondition=" '$(OS)' != 'Windows_NT'">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand> |
| 21 | + <PaketBootStrapperExePathCondition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath> |
| 22 | + <PaketBootStrapperExePathCondition=" '$(PaketBootStrapperExePath)' == ''">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath> |
| 23 | + <PaketBootStrapperCommandCondition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand> |
| 24 | + <PaketBootStrapperCommandCondition=" '$(OS)' != 'Windows_NT'">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand> |
| 25 | + |
| 26 | +<!-- Disable automagic references for F# dotnet sdk--> |
| 27 | +<!-- This will not do anything for other project types--> |
| 28 | +<!-- see https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1032-fsharp-in-dotnet-sdk.md--> |
| 29 | + <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference> |
| 30 | + <DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference> |
| 31 | + </PropertyGroup> |
| 32 | + |
| 33 | + <TargetName="PaketRestore"BeforeTargets="_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" > |
| 34 | + |
| 35 | +<!-- Step 1 Check if lockfile is properly restored--> |
| 36 | + <PropertyGroup> |
| 37 | + <PaketRestoreRequired>true</PaketRestoreRequired> |
| 38 | + <NoWarn>$(NoWarn);NU1603</NoWarn> |
| 39 | + </PropertyGroup> |
| 40 | + |
| 41 | + <PropertyGroupCondition="Exists('$(PaketRestoreCacheFile)')"> |
| 42 | + <PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash> |
| 43 | + <PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash> |
| 44 | + <PaketRestoreRequired>true</PaketRestoreRequired> |
| 45 | + <PaketRestoreRequiredCondition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)'">false</PaketRestoreRequired> |
| 46 | + <PaketRestoreRequiredCondition=" '$(PaketRestoreLockFileHash)' == ''">true</PaketRestoreRequired> |
| 47 | + </PropertyGroup> |
| 48 | + |
| 49 | +<!-- Do a global restore if required--> |
| 50 | + <ExecCommand='$(PaketBootStrapperCommand)'Condition="Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))"ContinueOnError="false" /> |
| 51 | + <ExecCommand='$(PaketCommand) restore'Condition=" '$(PaketRestoreRequired)' == 'true'"ContinueOnError="false" /> |
| 52 | + |
| 53 | +<!-- Step 2 Detect project specific changes--> |
| 54 | + <PropertyGroup> |
| 55 | + <PaketReferencesCachedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached</PaketReferencesCachedFilePath> |
| 56 | +<!-- MyProject.fsproj.paket.references has the highest precedence--> |
| 57 | + <PaketOriginalReferencesFilePath>$(MSBuildProjectFullPath).paket.references</PaketOriginalReferencesFilePath> |
| 58 | +<!-- MyProject.paket.references--> |
| 59 | + <PaketOriginalReferencesFilePathCondition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath> |
| 60 | +<!-- paket.references--> |
| 61 | + <PaketOriginalReferencesFilePathCondition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath> |
| 62 | + <PaketResolvedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).$(TargetFramework).paket.resolved</PaketResolvedFilePath> |
| 63 | + <PaketRestoreRequired>true</PaketRestoreRequired> |
| 64 | + <PaketRestoreRequiredReason>references-file-or-cache-not-found</PaketRestoreRequiredReason> |
| 65 | + </PropertyGroup> |
| 66 | + |
| 67 | +<!-- Step 2 a Detect changes in references file--> |
| 68 | + <PropertyGroupCondition="Exists('$(PaketOriginalReferencesFilePath)') AND Exists('$(PaketReferencesCachedFilePath)')"> |
| 69 | + <PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))</PaketRestoreCachedHash> |
| 70 | + <PaketRestoreReferencesFileHash>$([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))</PaketRestoreReferencesFileHash> |
| 71 | + <PaketRestoreRequiredReason>references-file</PaketRestoreRequiredReason> |
| 72 | + <PaketRestoreRequiredCondition=" '$(PaketRestoreReferencesFileHash)' == '$(PaketRestoreCachedHash)'">false</PaketRestoreRequired> |
| 73 | + </PropertyGroup> |
| 74 | + |
| 75 | + <PropertyGroupCondition="!Exists('$(PaketOriginalReferencesFilePath)') AND !Exists('$(PaketReferencesCachedFilePath)')"> |
| 76 | +<!-- If both don't exist there is nothing to do.--> |
| 77 | + <PaketRestoreRequired>false</PaketRestoreRequired> |
| 78 | + </PropertyGroup> |
| 79 | + |
| 80 | +<!-- Step 2 b detect relevant changes in project file (new targetframework)--> |
| 81 | + <PropertyGroupCondition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != ''"> |
| 82 | + <PaketRestoreRequired>true</PaketRestoreRequired> |
| 83 | + <PaketRestoreRequiredReason>target-framework '$(TargetFramework)'</PaketRestoreRequiredReason> |
| 84 | + </PropertyGroup> |
| 85 | + |
| 86 | +<!-- Step 3 Restore project specific stuff if required--> |
| 87 | + <MessageCondition=" '$(PaketRestoreRequired)' == 'true'"Importance="low"Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" /> |
| 88 | + <ExecCommand='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)"'Condition=" '$(PaketRestoreRequired)' == 'true'"ContinueOnError="false" /> |
| 89 | + |
| 90 | +<!-- This shouldn't actually happen, but just to be sure.--> |
| 91 | + <ErrorCondition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != ''"Text="A paket file for the framework '$(TargetFramework)' is missing. Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." /> |
| 92 | + |
| 93 | +<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild--> |
| 94 | + <ReadLinesFromFileCondition="Exists('$(PaketResolvedFilePath)')"File="$(PaketResolvedFilePath)" > |
| 95 | + <OutputTaskParameter="Lines"ItemName="PaketReferencesFileLines"/> |
| 96 | + </ReadLinesFromFile> |
| 97 | + |
| 98 | + <ItemGroupCondition=" Exists('$(PaketResolvedFilePath)') AND '@(PaketReferencesFileLines)' != ''" > |
| 99 | + <PaketReferencesFileLinesInfoInclude="@(PaketReferencesFileLines)" > |
| 100 | + <PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName> |
| 101 | + <PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion> |
| 102 | + </PaketReferencesFileLinesInfo> |
| 103 | + <PackageReferenceInclude="%(PaketReferencesFileLinesInfo.PackageName)"> |
| 104 | + <Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version> |
| 105 | + </PackageReference> |
| 106 | + </ItemGroup> |
| 107 | + |
| 108 | + <PropertyGroup> |
| 109 | + <RestoreConfigFile>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile> |
| 110 | + </PropertyGroup> |
| 111 | + |
| 112 | + </Target> |
| 113 | + |
| 114 | + <TargetName="PaketDisableDirectPack"AfterTargets="_IntermediatePack"BeforeTargets="GenerateNuspec"Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references')" > |
| 115 | + <PropertyGroup> |
| 116 | + <ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec> |
| 117 | + </PropertyGroup> |
| 118 | + </Target> |
| 119 | + |
| 120 | + <TargetName="PaketOverrideNuspec"AfterTargets="GenerateNuspec"Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references')" > |
| 121 | + <PropertyGroup> |
| 122 | + <PaketProjectFile>$(MSBuildProjectDirectory)/$(MSBuildProjectFile)</PaketProjectFile> |
| 123 | + <ContinuePackingAfterGeneratingNuspec>true</ContinuePackingAfterGeneratingNuspec> |
| 124 | + <UseNewPack>false</UseNewPack> |
| 125 | + <UseNewPackCondition=" '$(NuGetToolVersion)' != '4.0.0'">true</UseNewPack> |
| 126 | + </PropertyGroup> |
| 127 | + |
| 128 | + <ItemGroup> |
| 129 | + <_NuspecFilesInclude="$(BaseIntermediateOutputPath)*.nuspec"/> |
| 130 | + </ItemGroup> |
| 131 | + |
| 132 | + <ExecCommand='$(PaketCommand) fix-nuspecs files "@(_NuspecFiles)" project-file "$(PaketProjectFile)"'Condition="@(_NuspecFiles) != ''" /> |
| 133 | + |
| 134 | + <ConvertToAbsolutePathCondition="@(_NuspecFiles) != ''"Paths="@(_NuspecFiles)"> |
| 135 | + <OutputTaskParameter="AbsolutePaths"PropertyName="NuspecFileAbsolutePath" /> |
| 136 | + </ConvertToAbsolutePath> |
| 137 | + |
| 138 | +<!-- Call Pack--> |
| 139 | + <PackTaskCondition="$(UseNewPack)" |
| 140 | +PackItem="$(PackProjectInputFile)" |
| 141 | +PackageFiles="@(_PackageFiles)" |
| 142 | +PackageFilesToExclude="@(_PackageFilesToExclude)" |
| 143 | +PackageVersion="$(PackageVersion)" |
| 144 | +PackageId="$(PackageId)" |
| 145 | +Title="$(Title)" |
| 146 | +Authors="$(Authors)" |
| 147 | +Description="$(Description)" |
| 148 | +Copyright="$(Copyright)" |
| 149 | +RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)" |
| 150 | +LicenseUrl="$(PackageLicenseUrl)" |
| 151 | +ProjectUrl="$(PackageProjectUrl)" |
| 152 | +IconUrl="$(PackageIconUrl)" |
| 153 | +ReleaseNotes="$(PackageReleaseNotes)" |
| 154 | +Tags="$(PackageTags)" |
| 155 | +DevelopmentDependency="$(DevelopmentDependency)" |
| 156 | +BuildOutputInPackage="@(_BuildOutputInPackage)" |
| 157 | +TargetPathsToSymbols="@(_TargetPathsToSymbols)" |
| 158 | +TargetFrameworks="@(_TargetFrameworks)" |
| 159 | +AssemblyName="$(AssemblyName)" |
| 160 | +PackageOutputPath="$(PackageOutputAbsolutePath)" |
| 161 | +IncludeSymbols="$(IncludeSymbols)" |
| 162 | +IncludeSource="$(IncludeSource)" |
| 163 | +PackageTypes="$(PackageType)" |
| 164 | +IsTool="$(IsTool)" |
| 165 | +RepositoryUrl="$(RepositoryUrl)" |
| 166 | +RepositoryType="$(RepositoryType)" |
| 167 | +SourceFiles="@(_SourceFiles->Distinct())" |
| 168 | +NoPackageAnalysis="$(NoPackageAnalysis)" |
| 169 | +MinClientVersion="$(MinClientVersion)" |
| 170 | +Serviceable="$(Serviceable)" |
| 171 | +FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)" |
| 172 | +ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)" |
| 173 | +NuspecOutputPath="$(BaseIntermediateOutputPath)" |
| 174 | +IncludeBuildOutput="$(IncludeBuildOutput)" |
| 175 | +BuildOutputFolder="$(BuildOutputTargetFolder)" |
| 176 | +ContentTargetFolders="$(ContentTargetFolders)" |
| 177 | +RestoreOutputPath="$(RestoreOutputAbsolutePath)" |
| 178 | +NuspecFile="$(NuspecFileAbsolutePath)" |
| 179 | +NuspecBasePath="$(NuspecBasePath)" |
| 180 | +NuspecProperties="$(NuspecProperties)"/> |
| 181 | + |
| 182 | + <PackTaskCondition="! $(UseNewPack)" |
| 183 | +PackItem="$(PackProjectInputFile)" |
| 184 | +PackageFiles="@(_PackageFiles)" |
| 185 | +PackageFilesToExclude="@(_PackageFilesToExclude)" |
| 186 | +PackageVersion="$(PackageVersion)" |
| 187 | +PackageId="$(PackageId)" |
| 188 | +Title="$(Title)" |
| 189 | +Authors="$(Authors)" |
| 190 | +Description="$(Description)" |
| 191 | +Copyright="$(Copyright)" |
| 192 | +RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)" |
| 193 | +LicenseUrl="$(PackageLicenseUrl)" |
| 194 | +ProjectUrl="$(PackageProjectUrl)" |
| 195 | +IconUrl="$(PackageIconUrl)" |
| 196 | +ReleaseNotes="$(PackageReleaseNotes)" |
| 197 | +Tags="$(PackageTags)" |
| 198 | +TargetPathsToAssemblies="@(_TargetPathsToAssemblies->'%(FinalOutputPath)')" |
| 199 | +TargetPathsToSymbols="@(_TargetPathsToSymbols)" |
| 200 | +TargetFrameworks="@(_TargetFrameworks)" |
| 201 | +AssemblyName="$(AssemblyName)" |
| 202 | +PackageOutputPath="$(PackageOutputAbsolutePath)" |
| 203 | +IncludeSymbols="$(IncludeSymbols)" |
| 204 | +IncludeSource="$(IncludeSource)" |
| 205 | +PackageTypes="$(PackageType)" |
| 206 | +IsTool="$(IsTool)" |
| 207 | +RepositoryUrl="$(RepositoryUrl)" |
| 208 | +RepositoryType="$(RepositoryType)" |
| 209 | +SourceFiles="@(_SourceFiles->Distinct())" |
| 210 | +NoPackageAnalysis="$(NoPackageAnalysis)" |
| 211 | +MinClientVersion="$(MinClientVersion)" |
| 212 | +Serviceable="$(Serviceable)" |
| 213 | +AssemblyReferences="@(_References)" |
| 214 | +ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)" |
| 215 | +NuspecOutputPath="$(BaseIntermediateOutputPath)" |
| 216 | +IncludeBuildOutput="$(IncludeBuildOutput)" |
| 217 | +BuildOutputFolder="$(BuildOutputTargetFolder)" |
| 218 | +ContentTargetFolders="$(ContentTargetFolders)" |
| 219 | +RestoreOutputPath="$(RestoreOutputAbsolutePath)" |
| 220 | +NuspecFile="$(NuspecFileAbsolutePath)" |
| 221 | +NuspecBasePath="$(NuspecBasePath)" |
| 222 | +NuspecProperties="$(NuspecProperties)"/> |
| 223 | + </Target> |
| 224 | +<!--/+:cnd:noEmit--> |
| 225 | +</Project> |