-1
MarkupCompilePass1
を使用してxaml
〜baml
をコンパイルしています。これは、baml/xaml
リソースを指す相対パスの他に、かなりうまく機能しています。MarkupCompilePass1を使用してbaml/xamlの相対パスを設定します。
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/Sample01;component/ui/controls/test.xaml", System.UriKind.Relative);
#line 1 "test.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
しかし、それは現在、次のようになります:
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/Sample01;component/test.xaml", System.UriKind.Relative); // <--- Here is the problem
#line 1 "test.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
がどのように解決することができます例えば者は、生成されたコード(test.g.cs
)は次のようになりますよりも、XAMLファイルは、ディレクトリui/controls/test.xaml
であると仮定しましょうこの問題? /ui/controls
が含まれていないため、Uri
は完全ではありません。
ここでEDIT 1
はbaml
と*.g.cs
foreach (var _xaml in xamlSources)
{
// Relative path to the xaml file
_xaml.RelativePath = _xaml.RelativePath = Path.GetDirectoryName(_xaml.Path.Replace(CXUIBuildEngine.ProjectRoot, ""));
_task = new MarkupCompilePass1();
_task.BuildEngine = BuildEngine;
_task.RequirePass2ForMainAssembly = false;
_task.OutputType = "library";
// List of xaml to compile, im this case just one,
// because only one output is allowed so we have to set
// the specific output per compile process...
_task.PageMarkup = new[] { new XamlItem(_xaml.Path) };
// Set default namespace
if (!string.IsNullOrWhiteSpace(CXUIBuildEngine.RootNamespace))
{
_task.RootNamespace = CXUIBuildEngine.RootNamespace;
}
// Set default options
_task.AssemblyName = CXUIBuildEngine.AssemblyName;
_task.Language = "cs";
// !!! Here we combine the output path with the relative path,
// !!! This is maybe already the fault
_task.OutputPath = Path.Combine(TempOutputDirectory, _xaml.RelativePath);
// Add all references as XamlItem
if (CXUIBuildEngine.References != null)
{
_task.References = CXUIBuildEngine.References.Select(item => new XamlItem(item.Location)).ToArray();
}
if (!_task.Execute())
{
return false;
}
}
はあなたにたくさんありがとうござい生成し、現在のコードです! XamlPages
/Items
でLink
とLogicalName
を設定
* "MarkupCompilePass1'を使用して' xaml'を 'baml'にコンパイルしています" * - あなたはそれをやっていることを示すことができますか?私には、root(base)フォルダがxamlのどこにあるかのようにファイルをコンパイルしているようです。プロジェクトのルート(ベース)フォルダを使用してコンパイルする必要があります。その後、適切なパスが生成されます。 – Sinatr
@Sinatrジェネレータコードを追加しました。これは役に立ちますか?あなたの答えをありがとう! – BendEg
'OutputPath'がどのように見えるかを調べ、そこに相対パスを使用しようとします。 – Sinatr