123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?xml version="1.0" encoding="utf-8"?>
- <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
-
- <RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
-
- <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
-
- <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
-
- <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
- </PropertyGroup>
- <ItemGroup Condition=" '$(PackageSources)' == '' ">
-
-
-
- </ItemGroup>
- <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
-
- <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
-
- <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
- </PropertyGroup>
- <PropertyGroup>
- <PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
- <PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
- </PropertyGroup>
- <PropertyGroup>
- <PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
- <PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
- </PropertyGroup>
-
- <PropertyGroup>
-
- <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
- <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
- <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
- <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
- <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
- <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
- <NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
- <PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
- <PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
-
- <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
- <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
-
- <BuildDependsOn Condition="$(RestorePackages) == 'true'">
- RestorePackages;
- $(BuildDependsOn);
- </BuildDependsOn>
-
- <BuildDependsOn Condition="$(BuildPackage) == 'true'">
- $(BuildDependsOn);
- BuildPackage;
- </BuildDependsOn>
- </PropertyGroup>
- <Target Name="CheckPrerequisites">
-
- <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
-
- <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
- </Target>
- <Target Name="_DownloadNuGet">
- <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
- </Target>
- <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
- <Exec Command="$(RestoreCommand)"
- Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
- <Exec Command="$(RestoreCommand)"
- LogStandardErrorAsError="true"
- Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
- </Target>
- <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
- <Exec Command="$(BuildCommand)"
- Condition=" '$(OS)' != 'Windows_NT' " />
- <Exec Command="$(BuildCommand)"
- LogStandardErrorAsError="true"
- Condition=" '$(OS)' == 'Windows_NT' " />
- </Target>
- <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
- <ParameterGroup>
- <OutputFilename ParameterType="System.String" Required="true" />
- </ParameterGroup>
- <Task>
- <Reference Include="System.Core" />
- <Using Namespace="System" />
- <Using Namespace="System.IO" />
- <Using Namespace="System.Net" />
- <Using Namespace="Microsoft.Build.Framework" />
- <Using Namespace="Microsoft.Build.Utilities" />
- <Code Type="Fragment" Language="cs">
- <![CDATA[
- try {
- OutputFilename = Path.GetFullPath(OutputFilename);
- Log.LogMessage("Downloading latest version of NuGet.exe...");
- WebClient webClient = new WebClient();
- webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
- return true;
- }
- catch (Exception ex) {
- Log.LogErrorFromException(ex);
- return false;
- }
- ]]>
- </Code>
- </Task>
- </UsingTask>
- </Project>
|