Permalink
Browse files

Update project to use NuGet Automatic Restore

  • Loading branch information...
1 parent 2e114ce commit 6be1f150f101c0e0de708a8a339779bc1e5408dc @jrusbatch jrusbatch committed Feb 12, 2014
View
7 .nuget/NuGet.Config
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
- <solution>
- <add key="disableSourceControlIntegration" value="true" />
- </solution>
+ <packageRestore>
+ <add key="enabled" value="True" />
+ <add key="automatic" value="True" />
+ </packageRestore>
</configuration>
View
136 .nuget/NuGet.targets
@@ -1,136 +0,0 @@
-<?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>
-
- <!-- Enable the restore command to run before builds -->
- <RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
-
- <!-- Property that enables building a package from a project -->
- <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
-
- <!-- Determines if package restore consent is required to restore packages -->
- <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
-
- <!-- Download NuGet.exe if it does not already exist -->
- <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
- </PropertyGroup>
-
- <ItemGroup Condition=" '$(PackageSources)' == '' ">
- <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
- <!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
- <!--
- <PackageSource Include="https://www.nuget.org/api/v2/" />
- <PackageSource Include="https://my-nuget-source/nuget/" />
- -->
- </ItemGroup>
-
- <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
- <!-- Windows specific commands -->
- <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
- <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
- </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>
- </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>
-
- <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>
-
- <!-- Commands -->
- <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>
-
- <!-- We need to ensure packages are restored prior to assembly resolve -->
- <BuildDependsOn Condition="$(RestorePackages) == 'true'">
- RestorePackages;
- $(BuildDependsOn);
- </BuildDependsOn>
-
- <!-- Make the build depend on restore packages -->
- <BuildDependsOn Condition="$(BuildPackage) == 'true'">
- $(BuildDependsOn);
- BuildPackage;
- </BuildDependsOn>
- </PropertyGroup>
-
- <Target Name="CheckPrerequisites">
- <!-- Raise an error if we're unable to locate nuget.exe -->
- <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
- <!--
- 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;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>
View
14 build/Build.proj
@@ -13,9 +13,7 @@
<ArtifactsPath>$(BaseArtifactsPath)$(Configuration)\</ArtifactsPath>
<PackageOutputPath>$(BaseArtifactsPath)$(Configuration)</PackageOutputPath>
- <NuGetPath>$(Root).nuget\</NuGetPath>
- <NuGetExePath>$(NuGetPath)NuGet.exe</NuGetExePath>
- <NuGetProjectPath>$(NuGetPath)NuGet.targets</NuGetProjectPath>
+ <NuGetExePath>$(Root).nuget\NuGet.exe</NuGetExePath>
<CommonVersionInfoPath>$([System.IO.Path]::Combine( $(Root), 'common\CommonVersionInfo.cs' ))</CommonVersionInfoPath>
@@ -120,15 +118,9 @@
<Target Name="RestorePackages">
<Message Text="Restoring NuGet packages..." Importance="high" />
-
- <ItemGroup>
- <PackageConfigs Include="$(Root)**\packages.config" Exclude="$(BaseArtifactsPath)**\packages.config" />
- </ItemGroup>
- <CombinePackageConfigs PackageConfigFiles="@(PackageConfigs)" OutputPath="$(BaseArtifactsPath)packages.config" />
-
- <MSBuild Projects="$(NuGetProjectPath)" Targets="RestorePackages"
- Properties="SolutionDir=$(Root); RestorePackages=true; PackagesConfig=$(BaseArtifactsPath)packages.config" />
+ <Exec Command="&quot;$(NuGetExePath)&quot; restore -Verbosity detailed -NonInteractive"
+ WorkingDirectory="$(Root)" StandardOutputImportance="Low" />
</Target>
<Target Name="_CleanSolution">
View
1 src/ScriptCs.Contracts/ScriptCs.Contracts.csproj
@@ -72,5 +72,4 @@
<None Include="Properties\ScriptCs.Contracts.nuspec" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
View
1 src/ScriptCs.Core/ScriptCs.Core.csproj
@@ -70,5 +70,4 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
View
1 src/ScriptCs.Engine.Roslyn/ScriptCs.Engine.Roslyn.csproj
@@ -57,5 +57,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
View
1 src/ScriptCs.Hosting/ScriptCs.Hosting.csproj
@@ -97,7 +97,6 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
View
1 src/ScriptCs/ScriptCs.csproj
@@ -144,5 +144,4 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
View
1 test/ScriptCs.Core.Tests/ScriptCs.Core.Tests.csproj
@@ -96,5 +96,4 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
View
1 test/ScriptCs.Engine.Roslyn.Tests/ScriptCs.Engine.Roslyn.Tests.csproj
@@ -82,5 +82,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
View
1 test/ScriptCs.Hosting.Tests/ScriptCs.Hosting.Tests.csproj
@@ -94,5 +94,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</Project>
View
1 test/ScriptCs.Tests/ScriptCs.Tests.csproj
@@ -99,5 +99,4 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>

0 comments on commit 6be1f15

Please sign in to comment.