2017-02-22 144 views
7

我在我的ASP.NET Core MVC應用程序中選擇了「Xml documentation file」,它將「bin\Debug\net452\MyProject.xml」顯示爲輸出文件夾。問題是該文件在發佈文件夾中不存在。我需要額外的東西來包含它嗎?使用.NET Core 1.0-RC4和VS.NET 2017 RC4(新的csproject格式)。XML文檔文件不包含在發佈文件夾中

回答

3

顯然這不是用dotnet發佈實現的,而是在不久的將來:https://github.com/dotnet/sdk/issues/795

+1

代碼被合併到master中。儘管如此,還沒有發佈:https://github.com/dotnet/sdk/pull/1062 –

4

如果你使用project.json然後您就可以控制都包含和發佈過程中排除的文件和文件夾:

"publishOptions": { 
    "include": [ 
     "wwwroot", 
     "appsettings.json", 
     "appsettings.*.json", 
     "web.config" 
    ], 
    "exclude": [ 
     "wwwroot/less" 
    ] 
    } 

對於.csproj基於項目here is a good resource用於複製舊project.json設置XML,例如:

<ItemGroup> 
    <Compile Include="..\Shared\*.cs" Exclude="..\Shared\Not\*.cs" /> 
    <EmbeddedResource Include="..\Shared\*.resx" /> 
    <Content Include="Views\**\*" PackagePath="%(Identity)" /> 
    <None Include="some/path/in/project.txt" Pack="true" PackagePath="in/package.txt" /> 

    <None Include="notes.txt" CopyToOutputDirectory="Always" /> 
    <!-- CopyToOutputDirectory = { Always, PreserveNewest, Never } --> 

    <Content Include="files\**\*" CopyToPublishDirectory="PreserveNewest" /> 
    <None Include="publishnotes.txt" CopyToPublishDirectory="Always" /> 
    <!-- CopyToPublishDirectory = { Always, PreserveNewest, Never } --> 
</ItemGroup> 
+0

對不起忘了補充一點,我使用.NET的核心1.0 RC4和VS.NET 2017 RC4(新的csproject格式,沒有project.json)。 – dstr

+0

@dstr更新了我的答案,以包含一些'.csproj'信息,這些信息可能會幫助您指出正確的方向。 – Polynomial

1

project.json file s HOULD有"xmlDoc": true"buildOptions"

{ 
    "buildOptions": { 
     "xmlDoc": true 
    } 
} 

如果你有這樣的代碼中的文檔:

/// <summary> 
/// Documentation for FooClass 
/// </summary> 
public static class FooClass 
{ 
    // ... 
} 

那麼你應該有一個xml文件在你的輸出看起來像這樣:

<doc> 
    <assembly> 
     <name>Foo.Bar</name> 
    </assembly> 
    <members> 
     <member name="T:Foo.Bar.FooClass"> 
      <summary> 
      Documentation for FooClass 
      </summary> 
     </member> 
    </members> 
</doc> 
+0

很抱歉忘了補充一點,我使用.NET Core 1.0-RC4和VS.NET 2017 RC4(新的csproject格式,沒有project.json)。此外,我已經在我的輸出文件夾中生成了xml,但它沒有發佈到發佈文件夾。 – dstr

1

測試在1.1.2

ResolvedFileToPublish是發佈用途知道哪些文件就擺在發佈文件夾中的項目。 Include是文件的來源,而RelativePath是文件應放置在發佈文件夾內的位置。 h正如其名稱所暗示的那樣 - 它是收集所有待發布文件的目標。

<Target Name="CopyDocumentationFile" 
AfterTargets="ComputeFilesToPublish"> 
    <ItemGroup> 
    <ResolvedFileToPublish Include="@(FinalDocFile)" 
        RelativePath="@(FinalDocFile->'%(Filename)%(Extension)')" /> 
    </ItemGroup> 
</Target> 

就在這個目標添加到您的.csproj並確保 GenerateDocumentationFile設置爲true

<GenerateDocumentationFile>true</GenerateDocumentationFile>

https://github.com/dotnet/sdk/issues/795#issuecomment-289782712