diff --git a/src/DnnPackager/DnnPackager.csproj.user b/src/DnnPackager/DnnPackager.csproj.user
index 4768d4d..b27585f 100644
--- a/src/DnnPackager/DnnPackager.csproj.user
+++ b/src/DnnPackager/DnnPackager.csproj.user
@@ -4,6 +4,6 @@
ShowAllFiles
- build --envdteversion "14.0" --processid 1008--configuration "Debug" --name "DnnPackager.TestModule" --websitename "DotNetNuke"
+ build --envdteversion "14.0" --processid 5712 --configuration "Debug" --name "DnnPackager.TestModule" --websitename "DotNetNuke" --attach
\ No newline at end of file
diff --git a/src/DnnPackager/DotNetNukeWebAppInfo.cs b/src/DnnPackager/DotNetNukeWebAppInfo.cs
index 9d54637..32de045 100644
--- a/src/DnnPackager/DotNetNukeWebAppInfo.cs
+++ b/src/DnnPackager/DotNetNukeWebAppInfo.cs
@@ -158,7 +158,7 @@ public bool DeployPackages(FileInfo[] installZips, int retryAttempts, Action logger)
- {
+ {
// Try loop - Visual Studio may not respond the first time.
int tryCount = 5;
while (tryCount-- > 0)
@@ -18,20 +18,34 @@ public static bool Attach(int processId, EnvDTE.DTE dte, Action logger)
try
{
Processes processes = dte.Debugger.LocalProcesses;
- var targetProcess = processes.Cast().FirstOrDefault(proc => proc.ProcessID == processId);
- if (targetProcess == null)
+ Process targetProcess = null;
+ foreach (Process process in processes)
{
- return false;
+
+ if (process.ProcessID == processId)
+ {
+ targetProcess = process;
+ }
+ else
+ {
+ logger(String.Format("Skipped process named: {0} with Id {1}.", process.Name, process.ProcessID));
+ }
+ }
+
+ if (targetProcess != null)
+ {
+ logger(String.Format("Attaching to process {0}.", targetProcess.Name));
+ targetProcess.Attach();
+ logger(String.Format("Attached to process {0} successfully.", targetProcess.Name));
+ return true;
}
- targetProcess.Attach();
- logger(String.Format("Attached to process {0} successfully.", targetProcess.Name));
- return true;
+ return false;
}
catch (COMException)
{
- logger(String.Format("Trying to attach to processs.."));
+ logger(String.Format("Will retry attaching to process in a second.."));
System.Threading.Thread.Sleep(1000);
}
}
diff --git a/src/DnnPackager/Program.cs b/src/DnnPackager/Program.cs
index 5de162b..a7d0440 100644
--- a/src/DnnPackager/Program.cs
+++ b/src/DnnPackager/Program.cs
@@ -28,47 +28,66 @@ static int Main(string[] args)
if (!parsed)
{
Console.Write(options.GetUsage());
- Environment.Exit(-1);
+ return -1;
}
FileInfo[] installPackages = null;
+ DTE dte = null;
+ bool attachDebugger = false;
+ DotNetNukeWebAppInfo dnnWebsite = null;
switch (invokedVerb)
{
case "build":
- success = BuildProjectAndGetOutputZips((BuildOptions)invokedVerbInstance, out installPackages);
+ var buildArgs = (BuildOptions)invokedVerbInstance;
+ success = BuildProjectAndGetOutputZips(buildArgs, out installPackages, out dte);
+ attachDebugger = buildArgs.Attach;
break;
case "deploy":
installPackages = GetInstallZipsFromDirectory(((DeployOptions)invokedVerbInstance).DirectoryPath);
break;
}
+ dnnWebsite = GetDotNetNukeWebsiteInfo(invokedVerbInstance.WebsiteName);
+
if (installPackages != null && installPackages.Any())
- {
- var dnnWebsite = GetDotNetNukeWebsiteInfo(invokedVerbInstance.WebsiteName);
+ {
success = DeployToIISWebsite(installPackages, dnnWebsite);
}
else
{
-
+ // no packages to install.
+ // log warning?
+ LogInfo("No packages to install.");
+ success = true;
}
- if (success)
+ if (!success)
{
- return 0;
+ return -1;
}
- else
+
+ if (dte != null && attachDebugger)
{
- return -1;
+
+ LogInfo("Hooking up your debugger!");
+ var processId = dnnWebsite.GetWorkerProcessId();
+ if (!processId.HasValue)
+ {
+ LogInfo("Unable to find running worker process. Is your website running!?");
+ }
+ ProcessExtensions.Attach(processId.Value, dte, LogInfo);
}
+
+ return 0;
}
- private static bool BuildProjectAndGetOutputZips(BuildOptions options, out FileInfo[] installPackages)
+ private static bool BuildProjectAndGetOutputZips(BuildOptions options, out FileInfo[] installPackages, out DTE dte)
{
// Get an instance of the currently running Visual Studio IDE.
installPackages = null;
- EnvDTE.DTE dte = null;
+ dte = null;
string dteObjectString = string.Format("VisualStudio.DTE.{0}", options.EnvDteVersion);
string runningObjectName = string.Format("!{0}:{1}", dteObjectString, options.ProcessId);
@@ -95,7 +114,6 @@ private static bool BuildProjectAndGetOutputZips(BuildOptions options, out FileI
configurationName = options.Configuration;
}
-
// dte.Solution.SolutionBuild.Build(true);
var projects = dte.Solution.Projects;
var project = projects.OfType().FirstOrDefault(p => p.Name == options.ProjectName);
diff --git a/src/DnnPackager/packages.config b/src/DnnPackager/packages.config
index 5c714ac..ce6cc75 100644
--- a/src/DnnPackager/packages.config
+++ b/src/DnnPackager/packages.config
@@ -1,6 +1,5 @@
-
diff --git a/src/DnnPackager/tools/ModuleDeployment.psm1 b/src/DnnPackager/tools/ModuleDeployment.psm1
index 99f54ab..5eb2abb 100644
--- a/src/DnnPackager/tools/ModuleDeployment.psm1
+++ b/src/DnnPackager/tools/ModuleDeployment.psm1
@@ -11,7 +11,7 @@
if (!$buildConfigName)
{
- $solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
+ $solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
$solBuild = Get-Interface $solution.SolutionBuild ([EnvDTE.SolutionBuild])
$solActiveConfig = Get-Interface $solBuild.ActiveConfiguration ([EnvDTE.SolutionConfiguration])
$buildConfigName = [System.Convert]::ToString($solActiveConfig.Name)
@@ -19,13 +19,13 @@
if(!$attachFlag)
{
- Write-Host "Executing $commandPath iiswebsite $installPackagesPath $websiteName"
- & $commandPath "build --envdteversion " $dteVersion "--processid " $processId "--configuration " $buildConfigName "--name " $projectName "--websitename " $iisWebsiteName | Write-Host
+ Write-Host "Executing build --envdteversion $dteVersion --processid $processId --configuration $buildConfigName --name $projectName --websitename $iisWebsiteName"
+ & $commandPath "build --envdteversion " $dteVersion "--processid " $processId "--configuration " $buildConfigName "--name " $projectName "--websitename " $iisWebsiteName | Write-Host
}
else
{
- Write-Host "Executing $commandPath iiswebsite $installPackagesPath $websiteName"
- & $commandPath "build --envdteversion " $dteVersion "--processid " $processId "--configuration " $buildConfigName "--name " $projectName "--websitename " $iisWebsiteName " --attach" | Write-Host
+ Write-Host "Executing build --envdteversion $dteVersion --processid $processId --configuration $buildConfigName --name $projectName --websitename $iisWebsiteName --attach"
+ & $commandPath "build --envdteversion " $dteVersion "--processid " $processId "--configuration " $buildConfigName "--name " $projectName "--websitename " $iisWebsiteName " --attach" | Write-Host
}
}
@@ -36,8 +36,8 @@ function Get-ScriptDirectory {
function Get-Configurations()
{
- $solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
- $solBuild = Get-Interface $solution.SolutionBuild ([EnvDTE.SolutionBuild])
+ $solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
+ $solBuild = Get-Interface $solution.SolutionBuild ([EnvDTE.SolutionBuild])
$configs = $solBuild.SolutionConfigurations
$configs = [EnvDTE.SolutionConfigurations]::$solBuild.SolutionConfigurations
return $configs