Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaking WapBuilder to work correctly

  • Loading branch information...
commit 8e9f3f9e84fdc59185c028b9ea14897e61c764c2 1 parent 418ef24
@pranavkm pranavkm authored
View
57 Kudu.Core.Test/Deployment/WapBuilderFacts.cs
@@ -0,0 +1,57 @@
+using System.Collections.Generic;
+using Moq;
+using Xunit;
+using Xunit.Extensions;
+
+namespace Kudu.Core.Deployment.Test
+{
+ public class WapBuilderFacts
+ {
+ [Fact]
+ public void BuildProjectAppendsBuildPropertiesToExec()
+ {
+ // Arrange
+ var buildPropertyProvider = new Mock<IBuildPropertyProvider>();
+ buildPropertyProvider.Setup(s => s.GetProperties()).Returns(new Dictionary<string, string> {{ "ExtensionsPath", @"C:\Program Files" }, {"flp", "Detailed" }});
+ var wapBuilder = new WapBuilder(buildPropertyProvider.Object, @"x:\source-path", @"x:\project-path", @"x:\temp-path", @"x:\nuget-cache-path", @"x:\solution-dir\sol-path");
+
+ // Act
+ var commandLineParams = wapBuilder.GetMSBuildArguments(@"x:\temp-path\some-guid");
+
+ // Assert
+ Assert.Equal(@"""x:\project-path"" /nologo /verbosity:m /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir=""x:\temp-path\some-guid"";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:ExtensionsPath=""C:\Program Files"";flp=""Detailed"" /p:SolutionDir=""x:\solution-dir\\""", commandLineParams);
+ }
+
+ [Fact]
+ public void BuildProjectDoesNotAppendPropertyProviderProperties()
+ {
+ // Arrange
+ var buildPropertyProvider = new Mock<IBuildPropertyProvider>();
+ buildPropertyProvider.Setup(s => s.GetProperties()).Returns(new Dictionary<string, string>(0));
+ var wapBuilder = new WapBuilder(buildPropertyProvider.Object, @"x:\source-path", @"x:\project-path", @"x:\temp-path", @"x:\nuget-cache-path", @"x:\solution-dir\sol-path");
+
+ // Act
+ var commandLineParams = wapBuilder.GetMSBuildArguments(@"x:\temp-path\some-guid");
+
+ // Assert
+ Assert.Equal(@"""x:\project-path"" /nologo /verbosity:m /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir=""x:\temp-path\some-guid"";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir=""x:\solution-dir\\""", commandLineParams);
+ }
+
+ [Theory]
+ [InlineData(null)]
+ [InlineData("")]
+ public void BuildProjectDoesNotAppendSolutionDirIfSolutionPathIsNullOrEmpty(string solutionPath)
+ {
+ // Arrange
+ var buildPropertyProvider = new Mock<IBuildPropertyProvider>();
+ buildPropertyProvider.Setup(s => s.GetProperties()).Returns(new Dictionary<string, string>(0));
+ var wapBuilder = new WapBuilder(buildPropertyProvider.Object, @"x:\source-path", @"x:\project-path", @"x:\temp-path", @"x:\nuget-cache-path", solutionPath);
+
+ // Act
+ var commandLineParams = wapBuilder.GetMSBuildArguments(@"x:\temp-path\some-guid");
+
+ // Assert
+ Assert.Equal(@"""x:\project-path"" /nologo /verbosity:m /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir=""x:\temp-path\some-guid"";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release", commandLineParams);
+ }
+ }
+}
View
1  Kudu.Core.Test/Kudu.Core.Test.csproj
@@ -62,6 +62,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AuthUtilityFacts.cs" />
+ <Compile Include="Deployment\WapBuilderFacts.cs" />
<Compile Include="Infrastructure\MsBuildSiteBuilderFacts.cs" />
<Compile Include="Infrastructure\DisposableActionFacts.cs" />
<Compile Include="Infrastructure\ExecutableExtensionFacts.cs" />
View
2  Kudu.Core/Deployment/MsBuildSiteBuilder.cs
@@ -33,7 +33,7 @@ protected string GetPropertyString()
return String.Join(";", _propertyProvider.GetProperties().Select(p => String.Format("{0}=\"{1}\"", p.Key, p.Value)));
}
- public string ExecuteMSBuild(ITracer tracer, string arguments, params object[] args)
+ public virtual string ExecuteMSBuild(ITracer tracer, string arguments, params object[] args)
{
using (var writer = new ProgressWriter())
{
View
33 Kudu.Core/Deployment/WapBuilder.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -94,20 +95,32 @@ public override Task Build(DeploymentContext context)
return tcs.Task;
}
- private string BuildProject(ITracer tracer, string buildTempPath)
+ internal string BuildProject(ITracer tracer, string buildTempPath)
{
- string command = @"""{0}"" /nologo /verbosity:m /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir=""{1}"";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;";
- if (String.IsNullOrEmpty(_solutionPath))
- {
- command += "{2}";
- return ExecuteMSBuild(tracer, command, _projectPath, buildTempPath, GetPropertyString());
- }
+ string command = GetMSBuildArguments(buildTempPath);
- string solutionDir = Path.GetDirectoryName(_solutionPath) + @"\\";
- command += @"SolutionDir=""{2}"";{3}";
// Build artifacts into a temp path
- return ExecuteMSBuild(tracer, command, _projectPath, buildTempPath, solutionDir, GetPropertyString());
+ return ExecuteMSBuild(tracer, command);
+ }
+
+ internal string GetMSBuildArguments(string buildTempPath)
+ {
+ string command = @"""{0}"" /nologo /verbosity:m /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir=""{1}"";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release";
+ string properties = GetPropertyString();
+ if (!String.IsNullOrEmpty(properties))
+ {
+ command += " /p:" + properties;
+ }
+
+ string solutionDir = null;
+ if (!String.IsNullOrEmpty(_solutionPath))
+ {
+ solutionDir = Path.GetDirectoryName(_solutionPath) + @"\\";
+ command += @" /p:SolutionDir=""{2}""";
+ }
+ command = String.Format(CultureInfo.InvariantCulture, command, _projectPath, buildTempPath, solutionDir);
+ return command;
}
private void CleanBuild(ITracer tracer, string buildTempPath)
Please sign in to comment.
Something went wrong with that request. Please try again.