예제 #1
0
 protected void AddResourceAssembly(ZipFile zipFile, string packageCulture)
 {
     string entryName = String.Format(@"{0}\{1}.resources.dll", packageCulture, XapFilenameWithoutExtension);
     //string entryName = String.Format(@"{0}.resources.dll", XapFilenameWithoutExtension);
     //string sourceFile = Path.Combine(TargetDir, string.Format(@"{0}\{1}", packageCulture, entryName));
     string sourceFile = Path.Combine(TargetDir, entryName);
     zipFile.AddFile(sourceFile, entryName);
 }
예제 #2
0
        public override bool Execute()
        {
            if (String.IsNullOrEmpty(PackageCultures) || PackageCultures.Split(',').GetLength(0) == 0)
            {
                return true;
            }

            PackageCultures = PackageCultures.Replace(((char) 10).ToString(), "");
            PackageCultures = PackageCultures.Replace(((char) 13).ToString(), "");

            var xapOutputFiles = new List<string>();
            foreach (string packageCulture in PackageCultures.Split(','))
            {
                if (!String.IsNullOrEmpty(packageCulture))
                {
                    string xapResourceFilename = String.Format("{0}.{1}.xap", XapFilenameWithoutExtension, packageCulture);
                    var xapResourceFilePath = Path.Combine(TargetDir, xapResourceFilename);
                    Log.LogMessage("Creating XAP Resource file {0}", xapResourceFilePath);
                    var zipFile = new ZipFile(xapResourceFilePath);
                    zipFile.Create();
                    try
                    {
                        Log.LogMessage("Adding AppManifest.xaml");
                        AddAppManifest(zipFile, packageCulture);

                        Log.LogMessage("Adding Satellite Resource Assembly");
                        AddResourceAssembly(zipFile, packageCulture);

                        Log.LogMessage("Xap packaging completed successfully");
                    }
                    finally
                    {
                        zipFile.Close();
                    }

                    xapOutputFiles.Add(xapResourceFilePath);

                    if (!string.IsNullOrEmpty(PackagedCulturesOutputPath))
                    {
                        File.Copy(xapResourceFilePath, Path.Combine(PackagedCulturesOutputPath, xapResourceFilename), true);
                        Log.LogMessage(string.Format("Satellite Resource '{0}' copied to '{1}' successfully", xapResourceFilename, PackagedCulturesOutputPath));
                    }
                    else
                    {
                        Log.LogMessage("PackagedCulturesOutputPath is empty. Cannot copy to ClientBin!");
                    }
                }
            }

            XapOutputFiles = xapOutputFiles.ToArray();

            return true;
        }
예제 #3
0
        private void AddAppManifest(ZipFile zipFile, string packageCulture)
        {
            string appManifest = String.Format(
                @"<Deployment xmlns=""http://schemas.microsoft.com/client/2007/deployment"" " +
                @"xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">" + Environment.NewLine +
                @"  <Deployment.Parts>" + Environment.NewLine +
                @"    <AssemblyPart Source=""{0}"" />" + Environment.NewLine +
                @"  </Deployment.Parts>" + Environment.NewLine +
                @"</Deployment>",
                GetResourcesAssemblyPath(packageCulture));

            zipFile.AddEntry("AppManifest.xaml", Encoding.ASCII.GetBytes(appManifest));
        }