diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Compilation.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Compilation.targets index c8ec7205db..102315ebc4 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Compilation.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Compilation.targets @@ -42,6 +42,7 @@ Copyright (c) .NET Foundation. All rights reserved. Remove @(DocFileItem) Remove PdbFile="$(PdbFile)" Remove OutputRefAssembly="@(IntermediateRefAssembly)" + Remove MainEntryPoint="$(StartupObject)" Remove EmbedAllSources="$(EmbedAllSources)" - not supported by our supported version of MSBuild @@ -133,7 +134,6 @@ Copyright (c) .NET Foundation. All rights reserved. KeyFile="$(KeyOriginatorFile)" LangVersion="$(LangVersion)" LinkResources="@(LinkResource)" - MainEntryPoint="$(StartupObject)" ModuleAssemblyName="$(ModuleAssemblyName)" NoConfig="true" NoLogo="$(NoLogo)" diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs index 541cac3523..030f55dd7b 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs @@ -553,6 +553,21 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildPassed(result); } + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_WithStartupObjectSpecified_Works() + { + var result = await DotnetMSBuild("Build", $"/p:StartupObject=SimpleMvc.Program"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb"); + } + private static DependencyContext ReadDependencyContext(string depsFilePath) { var reader = new DependencyContextJsonReader();