Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating nuget.exe and target file in solution
- Loading branch information
Showing
4 changed files
with
138 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,79 +1,150 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | <PropertyGroup> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> | <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> | ||
</PropertyGroup> |
|
||
<!-- Enable the restore command to run before builds --> | |||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages> | |||
|
|
||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'"> | <!-- Property that enables building a package from a project --> | ||
<!-- Windows specific commands --> | <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage> | ||
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> | |||
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> | |||
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir> | |||
</PropertyGroup> | |||
|
|||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'"> | |||
<!-- We need to launch nuget.exe with the mono command if we're not on windows --> | |||
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath> | |||
<PackagesConfig>packages.config</PackagesConfig> | |||
<PackagesDir>$(SolutionDir)packages</PackagesDir> | |||
</PropertyGroup> | |||
|
|||
<Import Project="$(NuGetToolsPath)\sources" /> | |||
|
|||
<PropertyGroup> | |||
<!-- NuGet command --> | |||
<NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath> | |||
<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> | <!-- Determines if package restore consent is required to restore packages --> | ||
<RequireRestoreConsent>false</RequireRestoreConsent> | |||
|
|||
<!-- Download NuGet.exe if it does not already exist --> | |||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe> | |||
</PropertyGroup> | |||
|
|||
<ItemGroup Condition=" '$(PackageSources)' == '' "> | |||
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> | |||
<PackageSource Include="http://www.myget.org/F/kudu/" /> | |||
<PackageSource Include="https://nuget.org/api/v2/" /> | |||
</ItemGroup> | |||
|
|
||
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> | <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'"> | ||
<PackageSources Condition="$(PackageSources) == ''">""</PackageSources> | <!-- Windows specific commands --> | ||
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> | |||
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> | |||
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir> | |||
</PropertyGroup> | |||
|
|||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'"> | |||
<!-- We need to launch nuget.exe with the mono command if we're not on windows --> | |||
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath> | |||
<PackagesConfig>packages.config</PackagesConfig> | |||
<PackagesDir>$(SolutionDir)packages</PackagesDir> | |||
</PropertyGroup> | |||
|
|||
<PropertyGroup> | |||
<!-- NuGet command --> | |||
<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> | |||
|
|
||
<!-- Enable the restore command to run before builds --> | <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> | ||
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages> |
|
||
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch> | |||
<!-- Commands --> | |||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -o "$(PackagesDir)"</RestoreCommand> | |||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand> | |||
|
|
||
<!-- Property that enables building a package from a project --> | <!-- We need to ensure packages are restored prior to assembly resolve --> | ||
<BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage> | <ResolveReferencesDependsOn Condition="$(RestorePackages) == 'true'"> | ||
RestorePackages; | |||
$(ResolveReferencesDependsOn); | |||
</ResolveReferencesDependsOn> | |||
|
|
||
<!-- Commands --> | <!-- Make the build depend on restore packages --> | ||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand> | <BuildDependsOn Condition="$(BuildPackage) == 'true'"> | ||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand> | $(BuildDependsOn); | ||
BuildPackage; | |||
</BuildDependsOn> | |||
</PropertyGroup> | |||
|
|
||
<!-- Make the build depend on restore packages --> | <Target Name="CheckPrerequisites"> | ||
<BuildDependsOn Condition="$(RestorePackages) == 'true'"> | <!-- Raise an error if we're unable to locate nuget.exe --> | ||
RestorePackages; | <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> | ||
$(BuildDependsOn); | <SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " /> | ||
</BuildDependsOn> | <!-- | ||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once. | |||
This effectively acts as a lock that makes sure that the download operation will only happen once and all | |||
parallel builds will have to wait for it to complete. | |||
--> | |||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" /> | |||
</Target> | |||
|
|
||
<!-- Make the build depend on restore packages --> | <Target Name="_DownloadNuGet"> | ||
<BuildDependsOn Condition="$(BuildPackage) == 'true'"> | <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" /> | ||
$(BuildDependsOn); | </Target> | ||
BuildPackage; | |||
</BuildDependsOn> | |||
</PropertyGroup> | |||
|
|
||
<Target Name="CheckPrerequisites"> | <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> | ||
<!-- Raise an error if we're unable to locate nuget.exe --> | <Exec Command="$(RestoreCommand)" | ||
<Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> | Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" /> | ||
</Target> |
|
||
<Exec Command="$(RestoreCommand)" | |||
LogStandardErrorAsError="true" | |||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> | |||
</Target> | |||
|
|
||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> | <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites"> | ||
<Exec Command="$(RestoreCommand)" | <Exec Command="$(BuildCommand)" | ||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" /> | Condition=" '$(OS)' != 'Windows_NT' " /> | ||
|
|
||
<Exec Command="$(RestoreCommand)" | <Exec Command="$(BuildCommand)" | ||
LogStandardErrorAsError="true" | LogStandardErrorAsError="true" | ||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> | Condition=" '$(OS)' == 'Windows_NT' " /> | ||
</Target> | </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); | |||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites"> | Log.LogMessage("Downloading latest version of NuGet.exe..."); | ||
<Exec Command="$(BuildCommand)" | WebClient webClient = new WebClient(); | ||
Condition=" '$(OS)' != 'Windows_NT' " /> | webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename); | ||
|
|||
<Exec Command="$(BuildCommand)" | return true; | ||
LogStandardErrorAsError="true" | } | ||
Condition=" '$(OS)' == 'Windows_NT' " /> | catch (Exception ex) { | ||
</Target> | Log.LogErrorFromException(ex); | ||
return false; | |||
} | |||
]]> | |||
</Code> | |||
</Task> | |||
</UsingTask> | |||
|
|||
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> | |||
<ParameterGroup> | |||
<EnvKey ParameterType="System.String" Required="true" /> | |||
<EnvValue ParameterType="System.String" Required="true" /> | |||
</ParameterGroup> | |||
<Task> | |||
<Using Namespace="System" /> | |||
<Code Type="Fragment" Language="cs"> | |||
<![CDATA[ | |||
try { | |||
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process); | |||
} | |||
catch { | |||
} | |||
]]> | |||
</Code> | |||
</Task> | |||
</UsingTask> | |||
</Project> | </Project> |
This file was deleted.
Oops, something went wrong.