admin管理员组

文章数量:1401958

I've written a pair of .xaml/.targets file to handle the compilation of pixel shaders in WPF.

This is my xaml file:


<?xml version="1.0" encoding="utf-8"?>
<ProjectSchemaDefinitions xmlns=";
                          xmlns:x=";
                          xmlns:sys="clr-namespace:System;assembly=mscorlib">


    <ItemType Name="EffectShader"
              DisplayName="Wpf ShaderEffect Shader Compiler"
              />

    <ContentType Name="EffectShaderContent"
                 ItemType="EffectShader" />

    <FileExtension Name="*.fx"
                   ContentType="EffectShaderContent" />

</ProjectSchemaDefinitions>

and this is my .targets file:

<?xml version="1.0" encoding="utf-8" ?>
<Project>
    <ItemGroup>
        <PropertyPageSchema Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xaml" />
        <AvailableItemName Include="EffectShader">
            <Targets>EffectsShadersCompilation</Targets>
        </AvailableItemName>
    </ItemGroup>

    <Target Name="EffectsShadersCompilation"
            Condition="@(EffectShader)!=''"
            BeforeTargets="CoreCompile">

        <MakeDir Directories="$(IntermediateOutputPath)%(EffectShader.RelativeDir)"
                 Condition="!Exists('$(IntermediateOutputPath)%(EffectShader.RelativeDir)')"/>

        <Exec Command="&quot;$(WINSDK)/x64/fxc.exe&quot; %(EffectShader.Identity) /T ps_3_0 /E PSmain /O3 /Fo$(IntermediateOutputPath)%(EffectShader.RelativeDir)%(EffectShader.Filename).ps"
              Outputs="$(IntermediateOutputPath)%(EffectShader.RelativeDir)%(EffectShader.Filename).ps">
            <Output ItemName="CompiledEffectShader"
                    TaskParameter="Outputs" />
        </Exec>
        <ItemGroup>
            <Resource Include="@(CompiledEffectShader)" />
        </ItemGroup>
    </Target>
</Project>

This works fine and all, but when I want to access the properties of any of the EffectShader files, the properties are empty.

I just want to show something like in other files like this:

But MSBuild is like an undocumented mess for me. Can anybody help me telling what's missing?

Thanks in advance.

This is .csproj file

<Project Sdk="Microsoft.NET.Sdk">

    <Import Project="../ShadersCompilation.targets" />
    <PropertyGroup>
        <TargetFramework>net9.0-windows</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <UseWPF>true</UseWPF>
        <Authors>DrkWzrd</Authors>
        <Version>0.8.62</Version>
        <FileVersion>0.8.65</FileVersion>
        <AssemblyVersion>0.8.65</AssemblyVersion>

        <PackageLicenseExpression>MIT</PackageLicenseExpression>
        <Description>Variety of several extensions and tooling for wpf</Description>
        <NeutralLanguage>en-US</NeutralLanguage>
        <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
        <RootNamespace />
    </PropertyGroup>

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
        <ShouldCreateLogs>False</ShouldCreateLogs>
        <AdvancedSettingsExpanded>True</AdvancedSettingsExpanded>
        <UpdateAssemblyVersion>False</UpdateAssemblyVersion>
        <UpdateAssemblyFileVersion>False</UpdateAssemblyFileVersion>
        <UpdateAssemblyInfoVersion>False</UpdateAssemblyInfoVersion>
        <UpdatePackageVersion>True</UpdatePackageVersion>
        <AssemblyInfoVersionType>SettingsVersion</AssemblyInfoVersionType>
        <InheritWinAppVersionFrom>None</InheritWinAppVersionFrom>
        <PackageVersionSettings>AssemblyVersion.IncrementWithAutoReset.None</PackageVersionSettings>
    </PropertyGroup>

    <ItemGroup>
        <Compile Remove="System\Windows\Media\Imaging\QuadDistort.cs" />
    </ItemGroup>
    
    <ItemGroup>
        <PackageReference Include="Tools" Version="1.7.41" />
    </ItemGroup>

    <ItemGroup>
        <Compile Update="LibraryMessages.Designer.cs">
            <DesignTime>True</DesignTime>
            <AutoGen>True</AutoGen>
            <DependentUpon>LibraryMessages.resx</DependentUpon>
        </Compile>
    </ItemGroup>

    <ItemGroup>
        <EmbeddedResource Update="LibraryMessages.resx">
            <Generator>ResXFileCodeGenerator</Generator>
            <LastGenOutput>LibraryMessages.Designer.cs</LastGenOutput>
        </EmbeddedResource>
    </ItemGroup>

    <Import Project="../PushToGitHub.targets" />
</Project>

本文标签: visual studioMSBuild ItemType and custom Build Action doesn39t work as expectedStack Overflow