Created
February 22, 2012 04:22
-
-
Save half-ogre/1881335 to your computer and use it in GitHub Desktop.
A replacement for the NuGet.targets file that requires nuget.exe be on the path, so you don't have to commit it.
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- #### NOTE #### --> | |
<!-- To build with Mono's xbuild on bash, you must execute [`sudo install-nuget.sh`](https://gist.github.com/2595337) first. --> | |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> | |
<!-- Windows specific commands --> | |
<PackagesConfig Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> | |
<PackagesDir Condition=" '$(OS)' == 'Windows_NT'">$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir> | |
<LocatorCommand Condition=" '$(OS)' == 'Windows_NT'">where</LocatorCommand> | |
<!-- We need to launch nuget.exe with the mono command if we're not on windows --> | |
<PackagesConfig Condition=" '$(OS)' != 'Windows_NT' ">packages.config</PackagesConfig> | |
<PackagesDir Condition=" '$(OS)' != 'Windows_NT'">$(SolutionDir)packages</PackagesDir> | |
<LocatorCommand Condition=" '$(OS)' != 'Windows_NT'">which</LocatorCommand> | |
<!-- NuGet command --> | |
<NuGetCommand>nuget</NuGetCommand> | |
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> | |
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> | |
<PackageSources>""</PackageSources> | |
<!-- Enable the restore command to run before builds --> | |
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages> | |
<!-- Commands --> | |
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand> | |
<!-- Make the build depend on restore packages --> | |
<BuildDependsOn Condition="$(RestorePackages) == 'true'"> | |
RestorePackages; | |
$(BuildDependsOn); | |
</BuildDependsOn> | |
</PropertyGroup> | |
<Target Name="CheckPrerequisites"> | |
<!-- Try to locate `nuget`. --> | |
<Exec Command="$(LocatorCommand) $(NuGetCommand)" IgnoreExitCode="True"> | |
<Output TaskParameter="ExitCode" PropertyName="NuGetExeExitCode"/> | |
</Exec> | |
<!-- Raise an error if `nuget` wasn't located. --> | |
<Error Text="Failed to locate `nuget`; please make sure your PATH environment variable includes a path to `nuget`." Condition="'$(NuGetExeExitCode)' != '' and '$(NuGetExeExitCode)' != '0'" /> | |
</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> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment