2017-04-02 38 views
2

我想有一個.well-known目錄在我的根目錄中進行letsencrypt續訂。添加.well知道asp.net核心

我添加了一個路線.well-known像這樣:

app.UseStaticFiles(new StaticFileOptions 
     { 
      FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @".well-known")), 
      RequestPath = new PathString("/.well-known"), 
      ServeUnknownFileTypes = true // serve extensionless file 
     }); 

我添加了一個direcotry在我的wwwroot文件名爲.well-known但是當我發佈永遠不會被複制到輸出。

我試着將文件添加到它,並編輯的csproj:

<ItemGroup> 
    <Content Include="wwwroot\.well-known\" /> 
    </ItemGroup> 

每當我發佈我必須手動創建目錄。我如何得到它自動添加到wwwroot?

+0

發佈不包括空文件夾,你可以把一個dummy.txt文件,並將其包含在項目中? – Rob

+0

是的,我試着'我試着向它添加一個文件'對不起,應該已經更清楚了 – Guerrilla

+0

您是否也將它包含在Visual Studio項目中,並將其構建操作設置爲'Content'? – Rob

回答

3

我試着將文件添加到它,還可以編輯的csproj:

<ItemGroup> 
    <Content Include="wwwroot\.well-known\" /> 
</ItemGroup> 

無法通過內容文件夾複製過去,只有文件。您必須將其更改爲

<ItemGroup> 
    <Content Include="wwwroot\**"> 
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
    </Content> 
<ItemGroup> 

和類似註釋中提到的一樣,您需要在裏面放置一個空的虛擬文件。

+0

它的工作原理,我不得不建立一個虛擬文件,並設置內容爲「複製如果更新」 – Raffaeu

+1

@Raffaeu:這是完全一樣的上述。當您將VS IDE中的屬性設置爲「Copy if newer」時,它會在您的csproj中創建一個「「> PreserveNewest> Tseng