Blend4 の SketchFlow プロジェクトを実稼働プロジェクトに変換してみた - お だ のスペース でスクリプト書けそうと思ったので C# 用のを書いてみました。
実稼動プロジェクトに変換 の番号に合わせて書いてます。
※例外処理等何もしてません。自己責任でお願いします。(一応最初にバックアップは取ってます。)
パラメータは、大元のプロジェクトファイルがあるディレクトリと、実行時に最初に表示する画面の xaml ファイル名 です。
param([String]$rootPath="C:\Users\shinsuke\Documents\Expression\Blend 4\Projects\SilverlightPrototype1\SilverlightPrototype1",[String]$startUpXaml="画面_1.xaml") # 1. backup の作成 $backupPath = "$rootPath bak" Copy-Item $rootPath $backupPath -Recurse # 2.3 プロジェクトファイルを開く $rootProjPath = [System.IO.Directory]::GetFiles($rootPath,"*.csproj")[0]; $rootProjContent = [System.IO.File]::ReadAllText($rootProjPath); # 4. ExpressionBlendPrototypingEnbaled の削除 $rootProjContent = [System.Text.RegularExpressions.Regex]::Replace($rootProjContent, "\s*<ExpressionBlendPrototypingEnabled>false</ExpressionBlendPrototypingEnabled>\s*", ""); # 4. ExpressionBlendPrototypeHarness の削除 $rootProjContent = [System.Text.RegularExpressions.Regex]::Replace($rootProjContent, "\s*<ExpressionBlendPrototypeHarness>true</ExpressionBlendPrototypeHarness>\s*", ""); # 6.7. 参照の削除/追加 Microsoft.Expression.PrototypingRuntime の削除/System.Windows.Controls.Navigation の追加 $rootProjContent = [System.Text.RegularExpressions.Regex]::Replace($rootProjContent, "<Reference Include=""Microsoft.Expression.Prototyping.Runtime"" />", "<Reference Include=""System.Windows.Controls.Navigation"" />"); # 5. proj ファイルの保存 [System.IO.File]::WriteAllText($rootProjPath, $rootProjContent); # 8.9.10 Screen プロジェクトを開く $screenProjPath = ""; foreach ($dir in [System.IO.Directory]::GetDirectories($rootPath)) { $tmp = [System.IO.Directory]::GetFiles($dir, "*.csproj") if ($tmp.length -gt 0) { $screenProjPath = $tmp[0]; break; } } $screenProjContent = [System.IO.File]::ReadAllText($screenProjPath); # 11. ExpressionBlendPrototypingEnbaled の削除 $screenProjContent = [System.Text.RegularExpressions.Regex]::Replace($screenProjContent, "\s*<ExpressionBlendPrototypingEnabled>false</ExpressionBlendPrototypingEnabled>\s*", ""); # 11. ExpressionBlendPrototypeHarness の削除 $screenProjContent = [System.Text.RegularExpressions.Regex]::Replace($screenProjContent, "\s*<ExpressionBlendPrototypeHarness>true</ExpressionBlendPrototypeHarness>\s*", ""); # 13. 参照の削除 Microsoft.Expression.PrototypingRuntime の削除 $screenProjContent = [System.Text.RegularExpressions.Regex]::Replace($screenProjContent, "<Reference Include=""Microsoft.Expression.Prototyping.Runtime"" />\s*", ""); # 12. proj ファイルの保存 [System.IO.File]::WriteAllText($screenProjPath, $screenProjContent); #14. App.xaml.cs を開く $appXamlCsPath = [System.IO.Path]::Combine($rootPath, "App.xaml.cs"); $appXamlCsContent = [System.IO.File]::ReadAllText($appXamlCsPath); #15. assembly で指定している アセンブリ名の保持 & 削除 $pattern = "\[assembly: Microsoft\.Expression\.Prototyping\.Services\.SketchFlowLibraries\(""(?<name>[^""]*)""\)]" $assemblyName = [System.Text.RegularExpressions.Regex]::Match($appXamlCsContent, $pattern).Groups["name"].Value $appXamlCsContent = [System.Text.RegularExpressions.Regex]::Replace($appXamlCsContent, $pattern, ""); #16. App.xaml.cs の RootVisual 差し替え $rootVisualContent = [System.String]::Format("this.RootVisual = new System.Windows.Controls.Frame() {{ Source = new Uri(""/{0};component/{1}"", UriKind.Relative) }};", $assemblyName, $startUpXaml); $appXamlCsContent = $appXamlCsContent.Replace("this.RootVisual = new Microsoft.Expression.Prototyping.Workspace.PlayerWindow();", $rootVisualContent); [System.IO.File]::WriteAllText($appXamlCsPath, $appXamlCsContent);
SkyDrive から落とせるようにしています。不具合等ありましたら、コメント等でお知らせください。
SketchFlowConverter.zip