Comments (8)
Your build command/parameters appears to trigger a build and package/publish with a specific Publishing Profile (WebDeploy.pubxml) and so I suspect that the issue might be the convergence of three factors.
Can provide a few more details about your project? Specifically focus on the three areas described below:
PrecompileBeforePublish
Can you confirm that this publishing profile is set to have PreCompileBeforePublish
(If you open the WebDeploy.pubxml in the editor does it contain lines like the following)?
<PrecompileBeforePublish>true</PrecompileBeforePublish>
<EnableUpdateable>true</EnableUpdateable>
<DebugSymbols>false</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
When you have this PreCompileBeforePublish
it will utilize the $(IntermediateOutputPath)AspnetCompileMerge\Source
aka obj\AspnetCompileMerge\Source
directory to feed into the AspNetMergeCompiler.
MvcBuildViews
Can you confirm that you have not explicitly set the MvcBuildViews
property in your .csproj with something like this <MvcBuildViews>false<MvcBuildViews>
?
The default behavior for this SDK, is to set MvcBuildViews
to true when in Release
Configuration. This will execute several targets after the Afterbuild
target (meaning also after the Package
and AspNetPreCompile
targets)
- CleanupForBuildMvcViews - tries to partially clean the
$(IntermediateOutputPath)
by removing files from these subfolders Database;TransformWebConfig;CSAutoParameterize;InsertAdditionalCS;ProfileTransformWebConfig;Package. Note: the AspnetCompileMerge directory used by PreCompile is not cleaned of items - MvcBuildViews - performs a call to AspNetCompiler (a slightly more simplistic use of aspnetcompiler than is used in the above mentioned PreCompileBeforePublish process) which sees all files underneath the project directory (technically the
$(WebProjectOutputDir)
) including the "obj/"
Config File allowDefinition
Can you confirm that your project root web.config
either
- contains a section setting marked
allowDefinition="MachineToWebRoot"
? - contains a section that either the machine.config or applicationHost.config has already marked with
allowDefinition="MachineToWebRoot"
likemoduleProviders
,authorization
,dbManager
,protocols
Either of these in your project root web.config
will cause aspnet compiler errors if ever copied to a subfolder (and will cause aspnet compiler errors for the MvcBuildView target even when in a subfolder of the "obj/")
The allowDefinition
attribute when set in machine.config
; applicationHost.config
; Web.config
can prevent lower nested web.config files from attempting to set certain configurations
from msbuild.sdk.systemweb.
@p74DDone Thanks for confirming my suspicion that it is the MvcBuldViews step that is failing and that you had configured your publish profile to perform the precompile. You are correct that it would only ever happens during "Release" configuration builds.. This SDK enables MvcBuildViews
when in "Release" configuration, so it isn't happening during "Debug"
The MvcBuildViews
can be helpful for providing quick developer feedback when some code will error out during aspnet compilation. But it is not mandatory, and none of that step's output are included in the final build output.
You can disable it across the board (both local development and CICD Builds) by adding this into your "Etc.csproj"
<PropertyGroup>
<MvcBuildViews>false</MvcBuildViews>
</PropertyGroup>
Or you might use a conditional
to disable it only on your teamcity CI/CD builds
from msbuild.sdk.systemweb.
Quickly I can tell you that you don't need any of the Web.config lines in the csproj file as the SDK takes care of all that for you.
You should be able to pretty much remove all items from the project file and they should be picked up automatically.
Note - I do NOT recommend using <EnableWebFormsDefaultItems>false</EnableWebFormsDefaultItems>
.
from msbuild.sdk.systemweb.
I see this as well, but sporadically
from msbuild.sdk.systemweb.
Quickly I can tell you that you don't need any of the Web.config lines in the csproj file as the SDK takes care of all that for you. You should be able to pretty much remove all items from the project file and they should be picked up automatically.
Note - I do NOT recommend using
<EnableWebFormsDefaultItems>false</EnableWebFormsDefaultItems>
.
I've removed all the web.config references in the csproj and I've removed EnableWebFormsDefaultItems. Note I was using:
<EnableDefaultContentItems>false</EnableDefaultContentItems>
However, changing that to true and removing the content includes doesn't fix it either.
So right now, unfortunately I am still getting an identical error. Is there anything else you can suggest I try?
from msbuild.sdk.systemweb.
Hey, everything is configured as above already:
PrecompileBeforePublish
<PrecompileBeforePublish>true</PrecompileBeforePublish>
<EnableUpdateable>false</EnableUpdateable>
<DebugSymbols>false</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
MvcBuildViews
Can confirm this does not appear in the csproj file.
Config File allowDefinition
Can confirm that the webc.config does not contain any section, or the words, allowDefinition.
Other Info
- This only happens when publishing a Release build to generate the web deploy files (if I publish a Debug build it works fine)
- There are no other web.configs in any sub directories
- I have tried deleting the Web.Release.config and Web.Debug.config so I don't think it's related to the Web.Release.config and it doesn't have anything as above anyway
- I have cleared all bin and obj folders
- I have tried a fresh check-out
Is there anything else I can try or anything that would be helpful to provide? Here's the publish profile:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>Package</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<DesktopBuildPackageLocation>C:\Published\Package.zip</DesktopBuildPackageLocation>
<PackageAsSingleFile>true</PackageAsSingleFile>
<DeployIisAppPath>Default Web Site/EtcDemo</DeployIisAppPath>
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="etcConnectionString" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbDacFx">
<PreSource Path="Data Source=.\;Initial Catalog=Etc.16;Integrated Security=True;Connect Timeout=30;TrustServerCertificate=True" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\etcConnectionString_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="Data Source=.\;Initial Catalog=Etc.16;Integrated Security=true;Connect Timeout=30;TrustServerCertificate=True;" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
<ObjectGroup Name="redis" Order="8" Enabled="False">
<Destination Path="" />
<Object Type="DbDacFx">
<PreSource Path="localhost:6379" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\redis_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="localhost:6379" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>CustomCollectFiles;
;</CopyAllFilesToSingleFolderForMsdeployDependsOn>
<PrecompileBeforePublish>true</PrecompileBeforePublish>
<EnableUpdateable>false</EnableUpdateable>
<DebugSymbols>false</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
</PropertyGroup>
<PropertyGroup>
<OnBeforePackageUsingManifest>AddCustomSkipRules</OnBeforePackageUsingManifest>
</PropertyGroup>
<Target Name="AddCustomSkipRules">
<ItemGroup>
<MsDeploySkipRules Include="SkipDownloadsFiles">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>.*\\Exports\\.*$</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUploadsFolderDirectories">
<SkipAction>Delete</SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>.*\\Uploads\\</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUploadsFolderFiles">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>.*\\Uploads\\.*$</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipLicenceFile">
<SkipAction>Update</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>.*\\licence.lic</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipCustomImages">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>.*\\Images\\Custom\\.*$</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipAvatarImages">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>.*\\Images\\FollowableAvatars\\.*$</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipAvatarImages">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>.*\\Images\\FollowableAvatars\\.*$</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
</ItemGroup>
</Target>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="bin\Package.Api.xml" />
<_CustomFiles Include="bin\Package.Api.Models.xml" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)redis-Web.config Connection String" />
<MSDeployParameterValue Include="$(DeployParameterPrefix)etcConnectionString-Web.config Connection String" />
</ItemGroup>
</Project>
Final note
Something that is a bit odd is that it actually seems to generate all the publish files as expected. I haven't tested the installed output, but from a cursory check, all the files are generated and I can install it using the usual "projectname.webdeploy /y"
command.
from msbuild.sdk.systemweb.
Going through the command line log, it is successfully doing what I want it to do, but it then runs another MvcBuildViews thing which errors (note this project is a legacy project using WebForms, not MVC in case that's relevant):
Successfully executed Web deployment task.
Package "Project.zip" is successfully created as single file at the following location:
file:///C:/TeamCity/buildAgent3/work/21ab493d7c62fcd6/Published/Web
To get the instructions on how to deploy the web package please visit the following link:
https://go.microsoft.com/fwlink/?LinkId=124618
GenerateSampleDeployScript:
Sample script for deploying this package is generated at the following location:
C:\TeamCity\buildAgent3\work\21ab493d7c62fcd6\Published\Web\Etc.deploy.cmd
For this sample script, you can change the deploy parameters by changing the following file:
C:\TeamCity\buildAgent3\work\21ab493d7c62fcd6\Published\Web\Etc.SetParameters.xml
PipelineDeployPhase:
Publish Pipeline Deploy Phase
CleanupForBuildMvcViews:
**** SNIP - Lots of file deletions ****
MvcBuildViews:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p C:\Projects\Project\etc
30>C:\Projects\Point74\RP\RP2-1\Etc\obj\release\aspnetcompilemerge\source\web.config(96): error ASPCON
FIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application lev
el. This error can be caused by a virtual directory not being configured as an application in IIS. [C:\Projects
\Project\Etc\Etc.csproj]
30>Done Building Project "C:\Projects\Project\Etc\Etc.csproj" (default targets)
-- FAILED.
1>Done Building Project "C:\Projects\Project\Etc\Etc.sln" (default targets) -- FAILED.
So there's a final step that's occurring here after it's successfully compiled and published the zip file which then errors.
from msbuild.sdk.systemweb.
That seems to be working nicely now! Thanks for the help.
from msbuild.sdk.systemweb.
Related Issues (20)
- Central Package Management - Default Package Restore Failure HOT 9
- "ASP.NET Core Module is required" when running in Visual Studio HOT 10
- MSBuild.SDK.SystemWeb/4.0.82 projects do not load in Visual Studio 2022 17.5.0 HOT 10
- Setting RoslynToolPath to allow ASPX compilation with newer language versions HOT 8
- Launch Profiles editor no longer works in the latest versions of Visual Studio (17.5+)
- MSBuild.SDK.SystemWeb.RazorLibrary does not support GeneratedBindingRedirectsAction feature
- Microsoft.CodeDom.Providers.DotNetCompilerPlatform should use the latest version dependant on the target framework version HOT 1
- error : Could not open Source file: Could not find file 'Web.config;Web.config' HOT 1
- IIS Express profile launchSettings.json does not add environment variables in the iisexpress.exe process HOT 9
- Configuration-specific Web.configs added to project even if they don't exist
- GenerateBindingRedirects task emits warning without code - unable to suppress HOT 3
- Broken intellisense and aspnet warnings on WebForms projects HOT 26
- VsCode's new C# DevKit fails to launch HOT 7
- Auto added aspnetcore handler and "module" HOT 2
- Add support for autogenerated binding redirects that are not source controlled HOT 7
- Please Up-vote Resharper integration with MSBuild.SDK.SystemWeb HOT 1
- "Remove Unused References..." wants to remove everything HOT 3
- Issue with files copied to output folder HOT 2
- Support App_Browsers and App_Themes out of box HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msbuild.sdk.systemweb.