SoronelHaetir
SoronelHaetir

Reputation: 15162

Visual studio and custom msbuild task

I am working on a custom MSBuild task for invoking an existing source generation tool to reformat the error output so it matches Visual Studio's file name and line numbering expectations. I have this working to the point that if I build the project (either from the command line or within VS itself) my custom task runs and in the case of a build from within VS the build window output is as I desire.

However the Visual Studio project explorer does not actually show the input file. I have added AvailableItemName and PropertyPageSchema items, I have also added the file extension to Tools->Options, "Projects and Solutions"->"VC++ Project Settings", "Extensions to include" and even tried altering the extension list for the "Source files" group in my test project. what else am I missing?

Here is my .targets file (which I have added an .user.props (updated after realizing there were problems with the XML, but fixing that did not solve the solution explorer issue)

<?xml version="1.0" encoding="utf-8"?>
<ProjectSchemaDefinitions
    xmlns="http://schemas.microsoft.com/build/2009/properties"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <ItemType
    Name="ToolName"
    DisplayName="Tool" />

    <ContentType Name="ToolName" DisplayName="Tool Name" ItemType="ToolName">
    </ContentType>
    <FileExtension Name=".<ext>" ContentType="ToolName">
    </FileExtension>

    <Rule Name="ToolName" PageTemplate="tool" DisplayName="Tool" Order="5">
        <Rule.Categories>
            <Category Name="General" DisplayName="General" />
        </Rule.Categories>
        <Rule.DataSource>
            <DataSource Persistence="ProjectFile" ItemType="ToolName" Label="" HasConfigurationCondition="true" />
        </Rule.DataSource>
        <StringProperty Name="OutputFile" DisplayName="Output File" Description="Names the produced output file" Category="General"/>
        <StringProperty Name="HeaderFile" DisplayName="Header File" Description="Names the produced header file" Category="General"/>
        <StringProperty Name="ReportFile" DisplayName="Report File" Description="Names the produced report file" Category="General"/>
    </Rule>
</ProjectSchemaDefinitions>

Upvotes: 1

Views: 423

Answers (1)

SoronelHaetir
SoronelHaetir

Reputation: 15162

Okay, I was able to figure out what was wrong, it was a combination of the XML issues I fixed in the edit and then needing to restart VS rather than merely reloading my test project. After restarting (for something unrelated) my file now shows in solution explorer and correctly participates in dependency resolution (which was something I was going to ask about if I still had problems with it after getting the UI matter resolved).

Upvotes: 1

Related Questions