|
412 | 412 |
|
413 | 413 | <!-- Hook up .NET Core to enable solution refresh of packages --> |
414 | 414 | <PropertyGroup Condition="'$(TargetFramework)'=='coreclr'"> |
415 | | - |
416 | | - <NuGetPackagesPath Condition="'$(NuGetPackagesPath)' == ''">$(FSharpSourcesRoot)\..\packages</NuGetPackagesPath> |
417 | 415 |
|
418 | 416 | <!-- Implicitly needed by packageresolve.targets. Should file a bug for a better error message here --> |
419 | | - <PackagesDir>$(NuGetPackagesPath)\</PackagesDir> |
| 417 | + <PackagesDir>$(NUGET_PACKAGES)</PackagesDir> |
420 | 418 |
|
421 | 419 | <NuGetToolPath Condition="'$(NuGetToolPath)' == ''">$(FSharpSourcesRoot)\..\.nuget\</NuGetToolPath> |
422 | 420 | <NuGetConfigCommandLine>-ConfigFile "$(NuGetConfigFile)"</NuGetConfigCommandLine> |
423 | 421 |
|
424 | | - <NugetRestoreCommand>"$(NuGetToolPath)NuGet.exe install -OutputDirectory "$(NuGetPackagesPath)" -Config "$(NuGetToolPath)NuGet.Config"</NugetRestoreCommand> |
| 422 | + <NugetRestoreCommand>"$(NuGetToolPath)NuGet.exe install -OutputDirectory "$(PackagesDir)" -Config "$(NuGetToolPath)NuGet.Config"</NugetRestoreCommand> |
425 | 423 |
|
426 | | - <DnuRestoreCommand>"$(NuGetToolPath)NuGet.exe" restore -OutputDirectory "$(NuGetPackagesPath)" -Config "$(NuGetToolPath)NuGet.Config"</DnuRestoreCommand> |
| 424 | + <DnuRestoreCommand>"$(NuGetToolPath)NuGet.exe" restore -OutputDirectory "$(PackagesDir)" -Config "$(NuGetToolPath)NuGet.Config"</DnuRestoreCommand> |
427 | 425 |
|
428 | 426 | <!-- Current version of .NET Core does not support all semantics used in our packages, |
429 | 427 | so we ignore the pre-calculation in the lock file and calculate asset applicability in the build task --> |
|
473 | 471 | </Target> |
474 | 472 |
|
475 | 473 | <Target Name="dotnetrestore" BeforeTargets="Build" Condition=" '$(TargetFramework)' == 'coreclr' "> |
476 | | - <Exec Command="$(MSBuildThisFileDirectory)..\.nuget\nuget.exe restore -PackagesDirectory $(MSBuildThisFileDirectory)..\packages -Config $(MSBuildThisFileDirectory)..\.nuget\NuGet.Config project.json" /> |
477 | | - </Target> |
478 | | - |
479 | | - <Target Name="nugetpack" AfterTargets="Build" Condition="'$(TargetFramework)' == 'coreclr' " |
480 | | - Inputs="@(PackageNuspec)" Outputs='$(OutputPath.TrimEnd("\"))\nuget\"%(PackageNuspec.Filename)).nupkg'> |
481 | | - <PropertyGroup> |
482 | | - <PackageProperties>-prop "licenseUrl=$(PackageLicenceUrl)" -prop "version=$(PackageVersion)" -prop "authors=$(PackageAuthors)" -prop "projectUrl=$(PackageProjectUrl)" -prop "tags=$(PackageTags)"</PackageProperties> |
483 | | - </PropertyGroup> |
484 | | - |
485 | | - <Exec Command='$(MSBuildThisFileDirectory)..\.nuget\nuget.exe pack %(PackageNuspec.Filename)%(PackageNuspec.Extension) -BasePath "$(OutputPath.TrimEnd("\"))" -ExcludeEmptyDirectories $(PackageProperties) -OutputDirectory "$(MSBuildThisFileDirectory)..\artifacts' /> |
| 474 | + <Exec Command="$(MSBuildThisFileDirectory)..\.nuget\nuget.exe restore -PackagesDirectory $(PackagesDir) -Config $(MSBuildThisFileDirectory)..\.nuget\NuGet.Config project.json" /> |
486 | 475 | </Target> |
487 | 476 |
|
488 | 477 | <Target Name="dotnetrestore" BeforeTargets="Build" Condition=" '$(DOTNET_PUBLISH)' == 'true' "> |
| 478 | + <SetEnvVar Name="NUGET_PACKAGES" Value="$(NUGET_PACKAGES)" /> |
489 | 479 | <Exec Command="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe restore --configfile $(MSBuildThisFileDirectory)..\.nuget\NuGet.Config project.json"/> |
490 | 480 | </Target> |
491 | 481 |
|
492 | 482 | <Target Name="dotnetpublish" AfterTargets="Build" Condition=" '$(DOTNET_PUBLISH)' == 'true' "> |
| 483 | + <SetEnvVar Name="NUGET_PACKAGES" Value="$(NUGET_PACKAGES)" /> |
493 | 484 | <Exec Command="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe --verbose publish --no-build project.json -r $(DOTNET_PUBLISH_PLATFORM) -c $(Configuration) -o $(DOTNET_PUBLISH_PATH)"/> |
494 | 485 | </Target> |
495 | 486 |
|
496 | 487 | <Target Name="dotnetpublishfsccompiler" AfterTargets="CopyFilesToOutputDirectory" Condition=" '$(DOTNET_PUBLISH_FSC)' == 'true' "> |
| 488 | + <SetEnvVar Name="NUGET_PACKAGES" Value="$(NUGET_PACKAGES)" /> |
497 | 489 | <Exec Command="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe restore DeployCompiler\fsc\project.json"/> |
498 | 490 | <Exec Command="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe --verbose publish --no-build DeployCompiler\fsc\project.json -r $(DOTNET_PUBLISH_PLATFORM) -c $(Configuration) -o $(DOTNET_PUBLISH_FSC_PATH)"/> |
499 | 491 | </Target> |
500 | 492 |
|
501 | 493 | <Target Name="dotnetpublishfsicompiler" AfterTargets="CopyFilesToOutputDirectory" Condition=" '$(DOTNET_PUBLISH_FSI)' == 'true' "> |
| 494 | + <SetEnvVar Name="NUGET_PACKAGES" Value="$(NUGET_PACKAGES)" /> |
502 | 495 | <Exec Command="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe restore DeployCompiler\fsi\project.json"/> |
503 | 496 | <Exec Command="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe --verbose publish --no-build DeployCompiler\fsi\project.json -r $(DOTNET_PUBLISH_PLATFORM) -c $(Configuration) -o $(DOTNET_PUBLISH_FSI_PATH)"/> |
504 | 497 | </Target> |
|
518 | 511 | <WriteLinesToFile File="$(IntermediateOutputPath)source_link.json" Overwrite="true" Lines='{"documents": { "$(SrcRootDirectory)/*" : "$(RemoteUri.Replace(".git", "").Replace("github.com", "raw.githubusercontent.com"))/$(LatestCommit)/*" }}' /> |
519 | 512 | </Target> |
520 | 513 |
|
| 514 | + <!-- If BuildVersionFilePath not specified then do nothing --> |
| 515 | + <Target Name="CleanVersionFile" Condition ="'$(BuildVersionFilePath)' != '' "> |
| 516 | + <PropertyGroup> |
| 517 | + <BuildVersionFileDir>$([System.IO.Path]::GetDirectoryName($(BuildVersionFilePath)))</BuildVersionFileDir> |
| 518 | + </PropertyGroup> |
| 519 | + <RemoveDir Condition="Exists('$(BuildVersionFileDir)')" Directories="$(BuildVersionFileDir)" /> |
| 520 | + </Target> |
| 521 | + |
| 522 | + <!-- If BuildVersionFilePath not specified then do nothing --> |
| 523 | + <Target Name="CreateOrUpdateBuildVersionFile" Condition ="'$(BuildVersionFilePath)' != '' "> |
| 524 | + <PropertyGroup> |
| 525 | + <BuildVersionFileDir>$([System.IO.Path]::GetDirectoryName($(BuildVersionFilePath)))</BuildVersionFileDir> |
| 526 | + <PackageVersionMajor Condition="'$(PackageVersionMajor)' == ''" >$(NuGetPerBuildPreReleaseVersion)</PackageVersionMajor> |
| 527 | + <PackageVersionMinor Condition="'$(PackageVersionMinor)' != ''" >$([MSBuild]::Add($(PackageVersionMinor), 1))</PackageVersionMinor> |
| 528 | + <PackageVersionMinor Condition="'$(PackageVersionMinor)' == ''" >1</PackageVersionMinor> |
| 529 | + </PropertyGroup> |
| 530 | + |
| 531 | + <ItemGroup> |
| 532 | + <CurrentVersionLines Include="%3C%3Fxml version=%221.0%22 encoding=%22utf-8%22%3F%3E" /> |
| 533 | + <CurrentVersionLines Include="%3C!-- This is a generated file. $(VersionSeedSourceComment) Seed Date is $(VersionSeedDate). --%3E" /> |
| 534 | + <CurrentVersionLines Include="%3CProject xmlns=%22http://schemas.microsoft.com/developer/msbuild/2003%22%3E" /> |
| 535 | + <CurrentVersionLines Include="%3CPropertyGroup%3E" /> |
| 536 | + <CurrentVersionLines Include="%3CPackageVersionMajor Condition=%22%27%24(PackageVersionMajor)%27==%27%27%22%3E$(NuGetPerBuildPreReleaseVersion)%3C/PackageVersionMajor%3E" /> |
| 537 | + <CurrentVersionLines Include="%3CPackageVersionMinor Condition=%22%27%24(PackageVersionMinor)%27==%27%27%22%3E$(PackageVersionMinor)%3C/PackageVersionMinor%3E" /> |
| 538 | + <CurrentVersionLines Include="%3C/PropertyGroup%3E" /> |
| 539 | + <CurrentVersionLines Include="%3C/Project%3E" /> |
| 540 | + </ItemGroup> |
| 541 | + |
| 542 | + <!-- Since by default the file will get dropped at the obj dir, make sure that the dir is created already or else WriteLinesToFile will error. --> |
| 543 | + <MakeDir Condition="!Exists('$(BuildVersionFileDir)')" Directories="$(BuildVersionFileDir)" /> |
| 544 | + |
| 545 | + <WriteLinesToFile |
| 546 | + ContinueOnError="WarnAndContinue" |
| 547 | + File="$(BuildVersionFilePath)" |
| 548 | + Lines="@(CurrentVersionLines)" |
| 549 | + Overwrite="true" /> |
| 550 | + |
| 551 | + <!-- Delete old BuildVersion.props files --> |
| 552 | + <ItemGroup> |
| 553 | + <OldBuildVersionFiles Include="$(BuildVersionFilePath)BuildVersions-*.props" Exclude="$(BuildVersionFilePath)%(BuildVersionFileItem.Filename).props" /> |
| 554 | + </ItemGroup> |
| 555 | + <Delete Files="@(OldBuildVersionFiles)" TreatErrorsAsWarnings="true"/> |
| 556 | + </Target> |
| 557 | + |
| 558 | + <Target Name="nugetpack" |
| 559 | + DependsOnTargets="CreateOrUpdateBuildVersionFile" |
| 560 | + AfterTargets="Build" |
| 561 | + Condition="'$(TargetFramework)' == 'coreclr' " |
| 562 | + Inputs="@(PackageNuspec)" |
| 563 | + Outputs='$(FSharpSourcesRoot.TrimEnd("\"))\..\$(Configuration)\artifacts\"%(PackageNuspec.Filename)).nupkg'> |
| 564 | + |
| 565 | + <PropertyGroup> |
| 566 | + <PackageProperties>-prop "licenseUrl=$(PackageLicenceUrl)" -prop "version=$(PackageVersion)" -prop "authors=$(PackageAuthors)" -prop "projectUrl=$(PackageProjectUrl)" -prop "tags=$(PackageTags)"</PackageProperties> |
| 567 | + </PropertyGroup> |
| 568 | + |
| 569 | + <MakeDir Directories="$(FSharpSourcesRoot.TrimEnd('\'))\..\$(Configuration)\artifacts" /> |
| 570 | + <MakeDir Directories="$(FSharpSourcesRoot.TrimEnd('\'))\..\artifacts" /> |
| 571 | + <SetEnvVar Name="NUGET_PACKAGES" Value="$(NUGET_PACKAGES)" /> |
| 572 | + <Exec Command='$(MSBuildThisFileDirectory)..\.nuget\nuget.exe pack @(PackageNuspec) -BasePath $(OutputPath.TrimEnd("\")) -ExcludeEmptyDirectories $(PackageProperties) -OutputDirectory $(FSharpSourcesRoot.TrimEnd("\"))\..\$(Configuration)\artifacts' /> |
| 573 | + <Exec Command='$(MSBuildThisFileDirectory)..\.nuget\nuget.exe pack @(PackageNuspec) -BasePath $(OutputPath.TrimEnd("\")) -ExcludeEmptyDirectories $(PackageProperties) -OutputDirectory $(FSharpSourcesRoot.TrimEnd("\"))\..\artifacts' /> |
| 574 | + </Target> |
| 575 | + |
521 | 576 | <UsingTask TaskName="ReplaceFileText" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
522 | 577 | <ParameterGroup> |
523 | 578 | <InputFilename ParameterType="System.String" Required="true" /> |
|
541 | 596 | </Task> |
542 | 597 | </UsingTask> |
543 | 598 |
|
544 | | -</Project> |
| 599 | + <UsingTask TaskName="SetEnvVar" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
| 600 | + <ParameterGroup> |
| 601 | + <Name ParameterType="System.String" Required="true" /> |
| 602 | + <Value ParameterType="System.String" Required="true" /> |
| 603 | + </ParameterGroup> |
| 604 | + <Task> |
| 605 | + <Using Namespace="System" /> |
| 606 | + <Code Type="Fragment" Language="cs"> |
| 607 | + <![CDATA[ |
| 608 | + Environment.SetEnvironmentVariable(Name, Value); |
| 609 | + ]]> |
| 610 | + </Code> |
| 611 | + </Task> |
| 612 | + </UsingTask> |
| 613 | + |
| 614 | + </Project> |
0 commit comments