Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1835 handle auto-restore on twice #1836

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions integrationtests/Paket.IntegrationTests/AutoRestoreSpec.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Paket.IntegrationTests.AutoRestoreSpec

open System
open System.IO
open Fake
open NUnit.Framework
open FsUnit

[<Test>]
let ``#1835 auto-restore on downloads targets and updates proj file``() =
let scenario = "i001835-auto-restore-on-twice"
paket "auto-restore on" scenario |> ignore
let scenarioPath = scenarioTempPath scenario
Path.Combine(scenarioPath , ".paket","paket.targets") |> checkFileExists
let projectFile = File.ReadAllText(Path.Combine(scenarioPath, "AutoRestoreTwice" ,"AutoRestoreTwice.csproj"))
StringAssert.Contains("<Import Project=\"..\.paket\paket.targets\" />", projectFile)

[<Test>]
let ``#1835 auto-restore on twice same result as first run``() =
let scenario = "i001835-auto-restore-on-twice"
paket "auto-restore on" scenario |> ignore
// now running auto-restore a second time on the same project.
directPaket "auto-restore on" scenario |> ignore
let scenarioPath = scenarioTempPath scenario
Path.Combine(scenarioPath , ".paket","paket.targets") |> checkFileExists
let projectFile = File.ReadAllText(Path.Combine(scenarioPath, "AutoRestoreTwice" ,"AutoRestoreTwice.csproj"))
StringAssert.Contains("<Import Project=\"..\.paket\paket.targets\" />", projectFile)



Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<Compile Include="OutdatedSpecs.fs" />
<Compile Include="PackSpecs.fs" />
<Compile Include="InstallSpecs.fs" />
<Compile Include="AutoRestoreSpec.fs" />
<Compile Include="FrameworkRestrictionsSpecs.fs" />
<Compile Include="GroupSpecs.fs" />
<Compile Include="HttpSpecs.fs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{CD6F5013-BD01-4288-9851-5EF0390DE813}"
ProjectSection(SolutionItems) = preProject
paket.dependencies = paket.dependencies
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRestoreTwice", "AutoRestoreTwice\AutoRestoreTwice.csproj", "{703EF019-58C4-4D58-B9C0-F20080FD288D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{703EF019-58C4-4D58-B9C0-F20080FD288D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{703EF019-58C4-4D58-B9C0-F20080FD288D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{703EF019-58C4-4D58-B9C0-F20080FD288D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{703EF019-58C4-4D58-B9C0-F20080FD288D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{703EF019-58C4-4D58-B9C0-F20080FD288D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AutoRestoreTwice</RootNamespace>
<AssemblyName>AutoRestoreTwice</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace AutoRestoreTwice
{
public class Class1
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AutoRestoreTwice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoRestoreTwice")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("703ef019-58c4-4d58-b9c0-f20080fd288d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source C:\Tfs\Coromatic\Common\GuGet
source http://www.nuget.org/api/v2/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 3 additions & 2 deletions src/Paket.Core/VSIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ let TurnOffAutoRestore environment =
)
}


/// Activates the Visual Studio NuGet autorestore feature in all projects
let TurnOnAutoRestore environment =
let exeDir = Path.Combine(environment.RootDirectory.FullName, Constants.PaketFolderName)
Expand All @@ -34,7 +33,9 @@ let TurnOnAutoRestore environment =
do! downloadLatestBootstrapperAndTargets environment
let paketTargetsPath = Path.Combine(exeDir, Constants.TargetsFileName)

environment.Projects
// creating new projects after call to TurnOffAutoRestore to ensure they get saved.
let! projects = InstallProcess.findAllReferencesFiles(environment.RootDirectory.FullName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not the most elegant way.

projects
|> List.map fst
|> List.iter (fun project ->
let relativePath = createRelativePath project.FileName paketTargetsPath
Expand Down