我试图用webdeploy部署我的。NET核心2.1应用IIS服务器,但发布的应用程序后,没有文件夹和文件,包括从wwwroot文件之外在发布目录中,文件夹视图我只看到2查看页面和那些意见从除主项目之外的不同的库来,但没有产生认为属于主体工程。
public static void Main(string[] args)
{
CreateWebHostBuilder(args).UseDefaultServiceProvider(options =>
options.ValidateScopes = false).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
// For those 2 Views that are coming from another assembly (this 2 views are present in the Views folder of publish directory)
var myAssembly = typeof(Component).Assembly;
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddApplicationPart(myAssembly);
services.Configure<RazorViewEngineOptions>(options =>
{
options.FileProviders.Add(new EmbeddedFileProvider(myAssembly, "MyNS"));
});
//For serving static files from folder call Contents, outside of wwwroot
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(_env.ContentRootPath, "Contents")),
RequestPath = "/Contents"
});
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>........</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.0-preview3-35497">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0-preview3-35497" />
<PackageReference Include="morelinq" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Proj.Business\Proj.Business.csproj" />
<ProjectReference Include="..\Proj.Common\Proj.Common.csproj" />
<ProjectReference Include="..\Proj.Data\Proj.Data.csproj" />
<ProjectReference Include="..\MyNS\MyNS.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Contents\" CopyToPublishDirectory="PreserveNewest" />
<Folder Include="PrivateContents\" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
</Project>
我得到相同的结果,当我发布应用的目标Azure的应用服务,这有什么错我的应用程序?有什么额外的跟踪部署asp.net 2.1核心应用?请帮忙。
只是改变
<Folder Include="Contents\" CopyToPublishDirectory="PreserveNewest" />
<Folder Include="PrivateContents\" CopyToPublishDirectory="PreserveNewest" />
至
<Content Include="Contents\**\*" CopyToPublishDirectory="PreserveNewest" />
<Content Include="PrivateContents\**\*" CopyToPublishDirectory="PreserveNewest" />