今天继续在研究Silverlight的发布优化方法,由于项目需要开启OOB,没有办法再选中
这两个选项只能选择其中一个,很遗憾不能利用自身的功能合并项目了,这里说明一下,第一个选项的好处
如果你的解决方案中有两个Silverlight项目,那么如果选择了第一项,则两个项目中共同的DLL会被压缩放在ClientBin目录下,这样做的好处是避免了两个SL项目中引用重复的DLL,但是选择OOB之后,我们便不能选择这个项了,于是我想到在OOB的基础上,将打包好的XAP改成压缩文件,再解压,将两个项目中的公共DLL抽取出来放到ClientBin下,当然这样做还涉及到Xap包中的一个文件
<
Deployment
xmlns
="<a href="
http://schemas.microsoft.com/client/2007/deployment""
>
http://schemas.microsoft.com/client/2007/deployment"
</
a
>
xmlns:x=" < a href ="http://schemas.microsoft.com/winfx/2006/xaml" " > http://schemas.microsoft.com/winfx/2006/xaml" </ a > EntryPointAssembly="ProjectA"
EntryPointType="ProjectA.App" RuntimeVersion="4.0.50401.0">
< Deployment.OutOfbrowserSettings >
< OutOfbrowserSettings ShortName ="ProjectA Application" EnableGPUacceleration ="False"
ShowInstallMenuItem ="True" >
< OutOfbrowserSettings.Blurb > ProjectA Application on your desktop; at home, at work or on the
go. </ OutOfbrowserSettings.Blurb >
< OutOfbrowserSettings.WindowSettings >
< WindowSettings Title ="ProjectA Application" />
</ OutOfbrowserSettings.WindowSettings >
< OutOfbrowserSettings.Icons />
</ OutOfbrowserSettings >
</ Deployment.OutOfbrowserSettings >
< Deployment.Parts >
< AssemblyPart x:Name ="ProjectA" Source ="ProjectA.dll" />
< AssemblyPart x:Name ="ProjectB" Source ="ProjectB.dll" />
< AssemblyPart x:Name ="System.Windows.Controls" Source ="System.Windows.Controls.dll" />
< AssemblyPart x:Name ="Telerik.Windows.Controls" Source ="Telerik.Windows.Controls.dll" />
</ Deployment.Parts >
</ Deployment >
xmlns:x=" < a href ="http://schemas.microsoft.com/winfx/2006/xaml" " > http://schemas.microsoft.com/winfx/2006/xaml" </ a > EntryPointAssembly="ProjectA"
EntryPointType="ProjectA.App" RuntimeVersion="4.0.50401.0">
< Deployment.OutOfbrowserSettings >
< OutOfbrowserSettings ShortName ="ProjectA Application" EnableGPUacceleration ="False"
ShowInstallMenuItem ="True" >
< OutOfbrowserSettings.Blurb > ProjectA Application on your desktop; at home, at work or on the
go. </ OutOfbrowserSettings.Blurb >
< OutOfbrowserSettings.WindowSettings >
< WindowSettings Title ="ProjectA Application" />
</ OutOfbrowserSettings.WindowSettings >
< OutOfbrowserSettings.Icons />
</ OutOfbrowserSettings >
</ Deployment.OutOfbrowserSettings >
< Deployment.Parts >
< AssemblyPart x:Name ="ProjectA" Source ="ProjectA.dll" />
< AssemblyPart x:Name ="ProjectB" Source ="ProjectB.dll" />
< AssemblyPart x:Name ="System.Windows.Controls" Source ="System.Windows.Controls.dll" />
< AssemblyPart x:Name ="Telerik.Windows.Controls" Source ="Telerik.Windows.Controls.dll" />
</ Deployment.Parts >
</ Deployment >
我想将最后两个DLL抽取出来或者改变一下配置路径,但两种方法都没有用,有了解的朋友还请指点。
SharpZipLib 有兴趣的朋友可以试试
http://www.icsharpcode.net/OpenSource/SharpZipLib/
using
System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
namespace SLProjectsDownLoad.Web
{
public class Zip
{
public static void ZipFiles( string ZipFileName, string FromDirectory)
{
FastZip fz = new FastZip();
fz.CreateEmptyDirectories = true ;
fz.CreateZip(ZipFileName, FromDirectory, true , "" );
fz = null ;
}
public static void UnZipFiles( string ZipFileName, string ToDirectory)
{
if ( ! Directory.Exists(ToDirectory))
Directory.CreateDirectory(ToDirectory);
ZipInputStream s = new ZipInputStream(File.OpenRead(ZipFileName));
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null )
{
string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name);
if (directoryName != String.Empty)
Directory.CreateDirectory(ToDirectory + directoryName);
if (fileName != String.Empty)
{
FileStream streamWriter = File.Create(ToDirectory + theEntry.Name);
int size = 2048 ;
byte [] data = new byte [ 2048 ];
while ( true )
{
size = s.Read(data, 0 , data.Length);
if (size > 0 )
{
streamWriter.Write(data, size);
}
else
{
break ; } } streamWriter.Close(); } } s.Close(); } } }
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
namespace SLProjectsDownLoad.Web
{
public class Zip
{
public static void ZipFiles( string ZipFileName, string FromDirectory)
{
FastZip fz = new FastZip();
fz.CreateEmptyDirectories = true ;
fz.CreateZip(ZipFileName, FromDirectory, true , "" );
fz = null ;
}
public static void UnZipFiles( string ZipFileName, string ToDirectory)
{
if ( ! Directory.Exists(ToDirectory))
Directory.CreateDirectory(ToDirectory);
ZipInputStream s = new ZipInputStream(File.OpenRead(ZipFileName));
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null )
{
string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name);
if (directoryName != String.Empty)
Directory.CreateDirectory(ToDirectory + directoryName);
if (fileName != String.Empty)
{
FileStream streamWriter = File.Create(ToDirectory + theEntry.Name);
int size = 2048 ;
byte [] data = new byte [ 2048 ];
while ( true )
{
size = s.Read(data, 0 , data.Length);
if (size > 0 )
{
streamWriter.Write(data, size);
}
else
{
break ; } } streamWriter.Close(); } } s.Close(); } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。