*/\r
@NotNull\r
Collection<String> getNuGetPackageSources();\r
+\r
+ /**\r
+ * @return true if pacakges are expected to be installed\r
+ * without version\r
+ * numbers in directory names\r
+ */\r
+ boolean getExcludeVersion();\r
}\r
final List<String> argz = new ArrayList<String>();\r
argz.add("install");\r
argz.add(FileUtil.getCanonicalFile(packagesConfig).getPath()); //path to package\r
+ if (params.getExcludeVersion()) {\r
+ argz.add("-ExcludeVersion");\r
+ }\r
argz.add("-OutputDirectory");\r
argz.add(FileUtil.getCanonicalFile(targetFolder).getPath());\r
\r
import jetbrains.buildServer.agent.BuildRunnerContext;\r
import jetbrains.buildServer.nuget.agent.install.PackageInstallParametersFactory;\r
import jetbrains.buildServer.nuget.agent.install.PackagesInstallParameters;\r
-import jetbrains.buildServer.nuget.common.PackagesInstallerConstants;\r
import jetbrains.buildServer.util.FileUtil;\r
import jetbrains.buildServer.util.StringUtil;\r
import org.jetbrains.annotations.NotNull;\r
import java.util.Collections;\r
import java.util.List;\r
\r
+import static jetbrains.buildServer.nuget.common.PackagesInstallerConstants.*;\r
+\r
/**\r
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
* Date: 07.07.11 18:09\r
\r
@NotNull\r
public File getSolutionFile() throws RunBuildException {\r
- return resolvePath(PackagesInstallerConstants.SLN_PATH, "Visual Studio .sln file");\r
+ return resolvePath(SLN_PATH, "Visual Studio .sln file");\r
}\r
\r
@NotNull\r
public File getNuGetExeFile() throws RunBuildException {\r
- return resolvePath(PackagesInstallerConstants.NUGET_PATH, "nuget.exe");\r
+ return resolvePath(NUGET_PATH, "nuget.exe");\r
}\r
\r
@NotNull\r
public Collection<String> getNuGetPackageSources() {\r
- String sources = context.getRunnerParameters().get(PackagesInstallerConstants.NUGET_SOURCES);\r
+ String sources = context.getRunnerParameters().get(NUGET_SOURCES);\r
if (sources == null) return Collections.emptyList();\r
\r
List<String> list = new ArrayList<String>();\r
\r
return Collections.unmodifiableList(list);\r
}\r
+\r
+ public boolean getExcludeVersion() {\r
+ return !StringUtil.isEmptyOrSpaces(context.getRunnerParameters().get(NUGET_EXCLUDE_VERSION));\r
+ }\r
};\r
}\r
}\r
\r
public static final String NUGET_PATH = "nuget.path";\r
public static final String NUGET_SOURCES = "nuget.sources";\r
+ public static final String NUGET_EXCLUDE_VERSION = "nuget.excludeVersion";\r
public static final String SLN_PATH = "sln.path";\r
}\r
</l:settingsGroup>\r
\r
<l:settingsGroup title="Packages">\r
-<tr>\r
- <th>Path to solution file</th>\r
- <td>\r
- <props:textProperty name="${ib.solutionPathKey}" className="longField"/>\r
- <span class="smallNote">Specify path to Visual Studio solution file (.sln)</span>\r
- </td>\r
-</tr>\r
+ <tr>\r
+ <th>Path to solution file</th>\r
+ <td>\r
+ <props:textProperty name="${ib.solutionPathKey}" className="longField"/>\r
+ <span class="smallNote">Specify path to Visual Studio solution file (.sln)</span>\r
+ </td>\r
+ </tr>\r
+ <tr>\r
+ <th>Options</th>\r
+ <td>\r
+ <props:checkboxProperty name="${ib.excludeVersionKey}"/>\r
+ Exclude version from package folder names\r
+ <span class="smallNote">Makes NuGet exlude package version from package folders. Equivalent of -ExcludeVersion commandline argument</span>\r
+ </td>\r
+ </tr>\r
+\r
</l:settingsGroup>\r
<div class="parameter">\r
Path to .sln: <strong><props:displayValue name="${ib.solutionPathKey}"/></strong>\r
</div>\r
+\r
+<div class="parameter">\r
+ Exclude Version: <strong><props:displayCheckboxValue name="${ib.excludeVersionKey}"/></strong>\r
+</div>\r
public String getNuGetPathKey() { return PackagesInstallerConstants.NUGET_PATH; }\r
public String getNuGetSourcesKey() { return PackagesInstallerConstants.NUGET_SOURCES; }\r
public String getSolutionPathKey() { return PackagesInstallerConstants.SLN_PATH; }\r
+ public String getExcludeVersionKey() { return PackagesInstallerConstants.NUGET_EXCLUDE_VERSION;}\r
}\r
m.checking(new Expectations(){{\r
allowing(ps).getNuGetPackageSources(); will(returnValue(Collections.<String>emptyList()));\r
allowing(ps).getNuGetExeFile(); will(returnValue(nuget));\r
+ allowing(ps).getExcludeVersion(); will(returnValue(false));\r
\r
oneOf(myProcessFactory).executeCommandLine(\r
ctx,\r
m.assertIsSatisfied();\r
}\r
\r
+ @Test\r
+ public void test_no_sources_excludeVersion() throws RunBuildException, IOException {\r
+ final File nuget = createTempFile();\r
+ m.checking(new Expectations(){{\r
+ allowing(ps).getNuGetPackageSources(); will(returnValue(Collections.<String>emptyList()));\r
+ allowing(ps).getNuGetExeFile(); will(returnValue(nuget));\r
+ allowing(ps).getExcludeVersion(); will(returnValue(true));\r
+\r
+ oneOf(myProcessFactory).executeCommandLine(\r
+ ctx,\r
+ nuget,\r
+ Arrays.asList("install", myConfig.getPath(), "-ExcludeVersion", "-OutputDirectory", myTarget.getPath()),\r
+ myConfig.getParentFile()\r
+ );\r
+ }});\r
+\r
+ i.createBuildProcess(ctx, ps, myConfig, myTarget);\r
+ m.assertIsSatisfied();\r
+ }\r
+\r
@Test\r
public void test_sources() throws RunBuildException, IOException {\r
final File nuget = createTempFile();\r
m.checking(new Expectations(){{\r
allowing(ps).getNuGetPackageSources(); will(returnValue(Arrays.asList("aaa", "bbb")));\r
allowing(ps).getNuGetExeFile(); will(returnValue(nuget));\r
+ allowing(ps).getExcludeVersion(); will(returnValue(false));\r
\r
oneOf(myProcessFactory).executeCommandLine(\r
ctx,\r
public void test_01_online_sources() throws RunBuildException {\r
ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
\r
- fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList());\r
+ fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false);\r
\r
List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
System.out.println("installed packageses = " + packageses);\r
Assert.assertEquals(4, packageses.size());\r
}\r
\r
+ @Test\r
+ public void test_01_online_sources_ecludeVersion() throws RunBuildException {\r
+ ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
+\r
+ fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), true);\r
+\r
+ List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
+ System.out.println("installed packageses = " + packageses);\r
+\r
+ Assert.assertTrue(new File(myRoot, "packages/NUnit").isDirectory());\r
+ Assert.assertTrue(new File(myRoot, "packages/NInject").isDirectory());\r
+ Assert.assertTrue(new File(myRoot, "packages/Machine.Specifications").isDirectory());\r
+ Assert.assertEquals(4, packageses.size());\r
+ }\r
+\r
@Test(enabled = false, dependsOnGroups = "Need to understand how to check NuGet uses only specified sources")\r
public void test_01_local_sources() throws RunBuildException {\r
ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
File sourcesDir = new File(myRoot, "js");\r
ArchiveUtil.unpackZip(getTestDataPath("test-01-sources.zip"), "", sourcesDir);\r
\r
- fetchPackages(new File(myRoot, "sln1-lib.sln"), Arrays.asList("file:///" + sourcesDir.getPath()));\r
+ fetchPackages(new File(myRoot, "sln1-lib.sln"), Arrays.asList("file:///" + sourcesDir.getPath()), false);\r
\r
List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
System.out.println("installed packageses = " + packageses);\r
Assert.assertEquals(4, packageses.size());\r
}\r
\r
- private void fetchPackages(final File sln, final List<String> sources) throws RunBuildException {\r
+ private void fetchPackages(final File sln, final List<String> sources, final boolean excludeVersion) throws RunBuildException {\r
m.checking(new Expectations() {{\r
allowing(myParametersFactory).loadParameters(myContext);\r
will(returnValue(myParameters));\r
will(returnValue(sln));\r
allowing(myParameters).getNuGetPackageSources();\r
will(returnValue(sources));\r
+ allowing(myParameters).getExcludeVersion();\r
+ will(returnValue(excludeVersion));\r
}});\r
\r
BuildProcess proc = new PackagesInstallerRunner(\r