使用ClickOnce发布程序问题!能否拷贝文件到指定目录?
C/S程序,采用ClickOnce方式部署到应用服务器上
程序发布完后
要求安装时,能否把项目中某一目录下所有文件自动拷贝到c盘指定目录下?
-------------------------
困扰一天了,看哪位仁兄解决下,感谢!
右击winfor工程属性:页面栏目有
发布程序的一些设置,包括版本信息,发布位置... ...等信息
[解决办法]
可以换一个升级方式。看看这里
http://www.gofi.cn/#date.2007-6-4/
[解决办法]
"把项目中某一目录下所有文件"拷贝到应用程序的bin目录下.
然后,"右击winfor工程属性:页面栏目有"“应用程序文件”对话框,在里面包括进来发布的文件就会发布到客户端。
[解决办法]
贡献一个自动发布脚本,大家可以看看都有哪些步骤。
' ' 部署脚本
' ' 可接受参数 /s ,表示以静默模式运行,不弹出提示对话框
Dim ProjectName,BeginVersion,SourceFolder,UpdateUrl,CertFileName,CertFilePwd,PublishFolder
' ' 如果部署环境有变,请修改以下参数,文件路径以 "\ "结束
' ' ****************************************************************************
' ' 发布的源文件夹名称 , 注意:不是 bin 目录,而是 bin 的上级目录
SourceFolder = "d:\src\ "
' ' 发布位置,通常是 IIS 下的一个目录
PublishFolder = "d:\deploy\publish\ "
' ' 更新Url,即发布目录的http访问路径
UpdateUrl = "http://xx.xx.xx.xx/publish/ "
' ' ****************************************************************************
CertFileName = "xxx.pfx "
CertFilePwd = "xxx "
ProjectName = "xxx "
Dim ShowTip
ShowTip = True
Dim Args
If Wscript.Arguments.Count> 0 Then
Args = Wscript.Arguments(0) & " "
End If
If Args = "/s " Then
ShowTip = False
End If
Set fso = Wscript.CreateObject( "Scripting.FileSystemObject ")
ShowMsg(0)
' ' 从 Version.txt 读取版本号
Dim Version
Set objText = fso.OpenTextFile( "Version.txt ")
Version = objText.ReadAll()
Call objText.Close
' ' 版本累加
Version = Split(Version,vbCrLf)(0)
Dim ver1,ver2,ver3,ver4
ver1 = CInt(Split(Version, ". ")(0))
ver2 = CInt(Split(Version, ". ")(1))
ver3 = CInt(Split(Version, ". ")(2))
ver4 = CInt(Split(Version, ". ")(3))
ver4 = ver4 + 1
If ver4> =100 Then
ver4 = 0
ver3 = ver3 + 1
If ver3 > = 100 Then
ver3 = 0
ver2 = ver2 + 1
If ver2 > = 100 Then
ver2 = 0
ver1 = ver1 + 1
End If
End If
End If
Version = ver1 & ". " & ver2 & ". " & ver3 & ". " & ver4
' ' 保存最新版本号
fso.DeleteFile "Version.txt "
Set txt1 = fso.OpenTextFile( "Version.txt ",8,True)
txt1.Write Version & vbCrLf & " <Br> " & Date & " " & Time
Call txt1.Close
' ' 把当前版本文件覆盖到发布目录上
fso.CopyFile "Version.txt ",PublishFolder & "Version.txt ",True
' ' 建立版本目录
Dim i,DirectoryName
DirectoryName = PublishFolder & ProjectName & "_ " & Replace(Version, ". ", "_ ")
If fso.FolderExists(DirectoryName) Then fso.Delete(DirectoryName)
fso.CreateFolder(DirectoryName)
ShowMsg(1)
' ' 拷贝需要同步的文件到 PublishFiles 下
If SourceFolder <> " " Then
Dim SourBinFolder,DestFolder
DestFolder = DirectoryName
Set objText = fso.OpenTextFile( "DeployFiles.txt ")
Lines = objText.ReadAll()
Call objText.Close
Dim asynFiles
Dim asynFilesCount
asynFilesCount = 0
For Each Line in Split(Lines,VbCrLf)
i = i + 1
If fso.FileExists(SourceFolder & Line) Then
fso.CopyFile SourceFolder & Line , "PublishFiles\ " & Line , True
asynFilesCount = asynFilesCount + 1
End If
Next
' ' 把要发布的文件拷贝到IIS要发布的目录下
fso.CopyFolder "PublishFiles " , DirectoryName
' ' 拷贝文件结束
End If
ShowMsg(2)
Rem 建立应用程序清单
Set shell = WScript.CreateObject( "WScript.Shell ")
Dim cmdLine
cmdLine = "mage -New Application -FromDirectory " & DirectoryName & " -Version " & Version & " " _
& "-Name " & ProjectName & " -TrustLevel FullTrust -ToFile " _
& DirectoryName & "\ " & ProjectName & ".exe.manifest -CertFile " & CertFileName & " -Password " & CertFilePwd
Shell.Run cmdLine,1,TRUE
Dim dirName
dirName = ProjectName & "_ " & Replace(Version, ". ", "_ ")
cmdLine = "mage -u " & PublishFolder & ProjectName & ".application -AppCodeBase " & dirName & "\ " & ProjectName & ".exe.manifest " _
& "-AppManifest " & DirectoryName & "\ " & ProjectName & ".exe.manifest -cf " & CertFileName & " " _
& "-pwd " & CertFilePwd & " -pu " & UpdateUrl & ProjectName & ".application -v " & Version & " -n xxx管理系统 "
Shell.Run cmdLine,1,TRUE
ShowMsg(3)
Rem 给所有需要部署的文件加上后缀名称 .deploy
AddExtName fso,DirectoryName
Set fso = Nothing
Set Shell = Nothing
If ShowTip Then
MsgBox "成功完成 ClickOnce 部署,当前版本为: " & Replace(Version, "_ ", ". ")
End If
Sub AddExtName(f,FolderName)
For Each file In f.GetFolder(FolderName).Files
If file.Name <> ProjectName & ".exe.manifest " Then
file.Name = file.Name & ".deploy "
End If
Next
For Each folder In f.GetFolder(FolderName).SubFolders
AddExtName f,folder.Path
Next
End Sub
Sub ShowMsg(i)
If ShowTip Then
Dim msg(4)
msg(0) = "1 开始处理,建立版本目录... "
msg(1) = "2 开始拷贝需要部署的文件... "
msg(2) = "3 建立程序清单,更新部署清单... "
msg(3) = "4 为部署文件加上安全后缀 .deploy ... "
msg(4) = "5 部署完成 "
For t = 0 To 4
If t=i Then
msg(t) = "> " & msg(t)
Else
msg(t) = " " & msg(t)
End If
Next
MsgBox msg(0) & vbCrLf & msg(1) & vbCrLf & msg(2) & vbCrLf & msg(3) & vbCrLf & msg(4)
End If
End Sub