简体   繁体   English

Visual Studio和自定义msbuild任务

[英]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. 我正在执行一个自定义MSBuild任务,以调用现有的源生成工具来重新格式化错误输出,以使其与Visual Studio的文件名和行号期望匹配。 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. 我这样做的目的是,如果我(从命令行或在VS本身内)构建项目,则运行自定义任务,并且在VS内部进行构建的情况下,构建窗口输出是我想要的。

However the Visual Studio project explorer does not actually show the input file. 但是,Visual Studio项目资源管理器实际上并不显示输入文件。 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. 我已经添加了AvailableItemName和PropertyPageSchema项目,还向工具->选项,“项目和解决方案”->“ VC ++项目设置”,“要包括的扩展名”添加了文件扩展名,甚至尝试更改“源代码”的扩展名列表我的测试项目中的“文件”组。 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) 这是我的.targets文件(我添加了一个.user.props(在意识到XML存在问题后进行了更新,但是修复并未解决解决方案资源管理器问题)

<?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>

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. 好的,我能够找出问题所在,这是我在编辑中修复的XML问题的组合,然后需要重新启动VS,而不仅仅是重新加载测试项目。 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). 重新启动(针对不相关的内容)后,我的文件现在显示在解决方案资源管理器中,并且正确地参与了依赖项解析(这是我要问的问题,在解决UI问题后,是否仍然存在问题)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM