|
NOTE
This code calls
a .bat file that
you need to
populate with
any post-publish
processing you
want to do like
zipping.
You can tie this
to a hotkey
under
tools->options->keyboard
in Visual
Studio.
Option
Strict
Off
Option
Explicit
Off
Imports
System
Imports
EnvDTE
Imports
EnvDTE80
Imports
EnvDTE90
Imports
System.Diagnostics
Imports
System.IO
Imports
System.Text
Imports
System.Windows.Forms
Public
Module
Publish
Function
PublishAllProjectsInSolution()
As
Boolean
' Before using this
macro, the
certficate and
security zone must
be set.
' You can do this by
publishing the
projects using the
VS IDE.
Dim
slnbld2
As
SolutionBuild2 =
CType(DTE.Solution.SolutionBuild,
SolutionBuild2)
'Save changes to all
projects and clean.
For
Each
proj
As
Project
In
DTE.Solution.Projects
Try
If
Not
proj.Saved
Then
proj.Save()
Catch
ex
As
Exception
System.Diagnostics.Trace.WriteLine( "Can't
save "
+ proj.Name)
End
Try
Next
slnbld2.Clean( True)
For
Each
proj
As
Project
In
DTE.Solution.Projects
'Verify project is a
windows application
or console
application before
continuing
Dim
outputType
As
Integer
=
proj.Properties.Item("OutputType").Value
If
outputType <> 0
AndAlso
outputType <> 1
Then
Continue
For
End
If
'GenerateManifests
and SignManifests
must always to true
for publishing to
work.
proj.Properties.Item( "GenerateManifests").Value
=
True
proj.Properties.Item( "SignManifests").Value
=
True
proj.Save()
slnbld2.BuildProject(proj.ConfigurationManager.ActiveConfiguration.ConfigurationName,
proj.UniqueName,
True)
'only publish if
build was
successful.
If
slnbld2.LastBuildInfo
<> 0
Then
MsgBox( "Build
failed for "
& proj.UniqueName)
Else
slnbld2.PublishProject(proj.ConfigurationManager.ActiveConfiguration.ConfigurationName,
proj.UniqueName,
True)
If
slnbld2.LastPublishInfo
= 0
Then
'MsgBox("Publish
succeeded for " &
proj.UniqueName)
Return
True
Else
Return
False
End
If
End
If
Next
End
Function
Sub
PublishOLM()
If
(PublishAllProjectsInSolution())
Then
Dim
psiOpt
As
ProcessStartInfo =
New
ProcessStartInfo("c:\batchfiles\ZIPOLMemoPublish.bat")
psiOpt.UseShellExecute
=
True
''See this must be
set to false
Dim
process
As
System.Diagnostics.Process
= process.Start(psiOpt)
''//start the
process
process.WaitForExit()
End
If
End
Sub
End
Module
|