Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net webapi publish - xml files not copy

I have MVC 4.0 WebApi project with auto generated help based on this.

My model classes are stored it another projects in my solution. Generation of xml file is enabled for every project (Project Properties -> Build -> OutPut -> XML Documentation file - Enabled).

In local debug all is ok - xml files are copied to project directory and i see comments for fields / classes from another projects.

But when i use publish profile (to Folder), xml files don't copy to output folder. Only one xml file from main WebApi project is copied. So i don't see comments to classes from other projects.

like image 408
Alexander Subbotin Avatar asked May 15 '14 14:05

Alexander Subbotin


5 Answers

I had a similar issue, for the me the answer was a bit of a "doh!" moment.

In the project settings, I had only enabled the XML documentation file under the Debug configuration, and not under Release. I was deploying with Release, and so the XML documentation was not actually getting generated. So the fix was making sure to enable the XML documentation for both Debug and Release configurations.

like image 171
grimus Avatar answered Nov 10 '22 12:11

grimus


You can do it by two different way :

1) Go to your project property --> select build option --> check "XML documentation File" --> add path "App_data\XMLDocument.xml" --> save setting, build your project --> include your XMLDocument.xml file --> select property --> copy to output directory --> select "Copy always"

2) Go to your project property --> select "Package/Publish Web" option --> items to displays --> select "all files in this project" from dropdown

like image 20
Chandrika Prajapati Avatar answered Nov 10 '22 14:11

Chandrika Prajapati


I had the same problem, that only the xml file from the webapi project has been deployed.

To fix it, I had to add this to my Web(Api) project file, within the first PropertyGroup element.

<ExcludeXmlAssemblyFiles>false</ExcludeXmlAssemblyFiles>

After that, the documentation xml-files of all projects (where it's enabled) has been published!

like image 34
martinoss Avatar answered Nov 10 '22 12:11

martinoss


I was able to solve this using just a custom MSBuild target in the publish profile .pubxml file. Follow the steps below.

The end result is that this MSBuild target will copy all .xml files from the Web API's bin folder to the bin folder where you are publishing. No need to copy these files to App_Data.

1) Open the appropriate .pubxml file from [Project Folder]\Properties\PublishProfiles.

2) Add this snippet within the <Project><PropertyGroup> tag:

<CopyAllFilesToSingleFolderForPackageDependsOn>
  CustomCollectFiles;
  $(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>

<CopyAllFilesToSingleFolderForMsdeployDependsOn>
  CustomCollectFiles;
  $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>

3) Add this snippet after the <PropertyGroup> tag:

      <Target Name="CustomCollectFiles">
        <ItemGroup>
          <_CustomFiles Include="bin\*.xml" />

          <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
            <DestinationRelativePath>bin\%(Filename)%(Extension)</DestinationRelativePath>
          </FilesForPackagingFromProject>
        </ItemGroup>
      </Target>

Credit goes to this answer which was addressing how to include files from outside the project directory when publishing.

like image 29
Keith Avatar answered Nov 10 '22 14:11

Keith


Open your publishprofile (*.pubxml) and include this code into "Project" element:

<ItemGroup>
    <Content Include="bin\yourDocumentationFile.xml">
        <CopyToOutputDirectory>true</CopyToOutputDirectory>
    </Content>
    <!-- Include a content to each documentation file -->
</ItemGroup>
like image 8
Leandro Escaldelai Avatar answered Nov 10 '22 13:11

Leandro Escaldelai