这是我正在尝试做的,但到目前为止还没有成功。我有一个带有一些 xaml 类的 WPF 项目。我有一个 msbuild 任务,它创建与 xaml 类同名但具有一些额外属性的部分类。部分类被正确创建并且构建也很好。但是,新创建的属性不会显示在 VS2010 中的 Intellisense 上。我也在使用 Resharper。
我已经在原始 .csproj 文件中导入了我的目标。原始文件粘贴在问题的末尾。
<Import Project="..\XamlModifyTask\bin\Debug\TXamlModifyTask.csproj" />
这就是 TXamlModifyTask.csproj 的样子
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<UsingTask AssemblyFile="XamlModifyTask.dll" TaskName="XamlModifyTask"/>
<!--PropertyGroup>
<ResolveReferencesDependsOn>XamlModify;$(ResolveReferencesDependsOn)</ResolveReferencesDependsOn>
</PropertyGroup-->
<PropertyGroup>
<CompileDependsOn>XamlModify;$(CompileDependsOn)</CompileDependsOn>
</PropertyGroup>
<ItemGroup>
<SettingsGenerated Include="$(IntermediateOutputPath)**\*.test.cs"></SettingsGenerated>
</ItemGroup>
<Target Name="XamlModify">
<XamlModifyTask Files="@(Page)" OutputPath="$(IntermediateOutputPath)"></XamlModifyTask>
<ItemGroup>
<Compile Include="@(SettingsGenerated)"></Compile>
<FileWrites Include="@(SettingsGenerated)"/>
</ItemGroup>
</Target>
我什至尝试过使用 BeforeCompile/BeforeBuild 事件。但它不起作用。我在这里做错什么了吗。
这是原始项目文件。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="JPMorgan.Build.XamlModifyTask" AssemblyFile="H:\Visual Studio 2010\Projects\WpfApplication1\WpfApplication1\JPMorgan.Build.dll" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{55A24932-DA31-4837-9E1E-9E69C34BFB5F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WpfApplication1</RootNamespace>
<AssemblyName>WpfApplication1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="View\Window1.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon>
</Compile>
<Compile Include="Window2.xaml.cs">
<DependentUpon>Window2.xaml</DependentUpon>
</Compile>
<Compile Include="Window4.xaml.cs">
<DependentUpon>Window4.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="View\Window1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window3.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="Window3.xaml.cs">
<DependentUpon>Window3.xaml</DependentUpon>
</Compile>
<Page Include="Window4.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\XamlModifyTask\bin\Debug\TXamlModifyTask.csproj" />
<!--Target Name="BeforeBuild">
<ItemGroup>
<Compile Include="@(SettingsGenerated)"></Compile>
<FileWrites Include="@(SettingsGenerated)"/>
</ItemGroup>
</Target-->
<!--Target Name="AfterBuild">
</Target-->
</Project>