【发布时间】:2019-10-10 01:26:39
【问题描述】:
每次构建 .NET Core 项目时,它都会在\bin\release 中添加一个包含.csproj 文件的更深的文件夹。结果是以下文件夹结构:
D:\home>
D:\home\site>
D:\home\site\repository>
D:\home\site\repository\bin>
D:\home\site\repository\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release>
当执行更多构建时,这会继续增长。
在 Visual Studio 中,清理和重建有助于解决这个问题。几次构建后,文件名变得太长,在尝试运行应用程序时引发错误。
起初,这并不重要,但在将 WebApp-Bot 部署到 Azure 时,也会发生同样的情况。问题是我无法从服务器中删除过多的文件。这就是为什么我需要阻止它发生。
.csproj 文件:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>SOME_USER_SECRETS_ID</UserSecretsId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Remove="%2a%2a\**" />
<Content Remove="%2a%2a\**" />
<EmbeddedResource Remove="%2a%2a\**" />
<None Remove="%2a%2a\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Gremlin.Net" Version="3.4.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.4.3" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.4.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.4.3" />
<PackageReference Include="Microsoft.Recognizers.Text.DataTypes.TimexExpression" Version="1.1.6" />
</ItemGroup>
<Import Project="PostDeployScripts\IncludeSources.targets" Condition="Exists('PostDeployScripts\IncludeSources.targets')" />
<Import Project="..\PostDeployScripts\IncludeSources.targets" Condition="Exists('..\PostDeployScripts\IncludeSources.targets')" />
<ItemGroup>
<None Remove="%2a%2a\%2a.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="bin\" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties Properties_4launchSettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project>
我现在看到的includesources.targets 带有always 标志:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="**\*.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
<None Include="**\*.csproj" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PostDeployScripts\*.*" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
我想知道为什么会发生这种情况以及如何阻止它,欢迎所有帮助。
【问题讨论】:
-
你能分享你的csproj吗?或者你可以在一个最小的项目中重新创建它吗?
-
将文件添加到帖子中,大部分内容与 Microsoft 的 Webapp-Bot 示例中的内容相同
-
我感觉是这部分:
<ItemGroup><Folder Include="bin\" /></ItemGroup>可能告诉 MSBuild 包含 bin 目录,该目录已经包含发布目录,然后将包含另一个 bin 目录,它将.. ..如果你赶上我的漂移 -
IncludeSources.targets包含什么? -
@JamieTaylor
<Folder>items 只告诉 VS 显示文件夹,即使它是空的。
标签: visual-studio azure .net-core botframework azure-web-app-service