Hi,
I am having issue publishing a Web App to Azure, using MSBuild command.
Seems like issue is happening because of using “using System.Security.Claims;”.
I have a sample web application, Visual Studio 2017, c#, Web Site project.
On my web page, I simply added “using System.Security.Claims;”, no any other code.
I have saved my “SampleWebSite1-WebDeploy.pubxml” file which is as below.
============================================================================================================================
<?xml version="1.0" encoding="utf-8"?><!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
--><Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><WebPublishMethod>MSDeploy</WebPublishMethod><ADUsesOwinOrOpenIdConnect>False</ADUsesOwinOrOpenIdConnect><PublishProvider>AzureWebSite</PublishProvider><LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration><LastUsedPlatform>Any CPU</LastUsedPlatform><SiteUrlToLaunchAfterPublish>XXX</SiteUrlToLaunchAfterPublish><LaunchSiteAfterPublish>True</LaunchSiteAfterPublish><ExcludeApp_Data>True</ExcludeApp_Data><MSDeployServiceURL>XXX</MSDeployServiceURL><DeployIisAppPath>SampleWebApplication1</DeployIisAppPath><RemoteSitePhysicalPath /><SkipExtraFilesOnServer>True</SkipExtraFilesOnServer><MSDeployPublishMethod>WMSVC</MSDeployPublishMethod><EnableMSDeployBackup>True</EnableMSDeployBackup><UserName>$SampleWebApplication1</UserName><Password>XXX</Password><_SavePWD>True</_SavePWD><_DestinationType>AzureWebSite</_DestinationType><EnableUpdateable>False</EnableUpdateable><DebugSymbols>False</DebugSymbols><WDPMergeOption>DonotMerge</WDPMergeOption><PrecompileBeforePublish>True</PrecompileBeforePublish><ExcludeFilesFromDeployment>web.config</ExcludeFilesFromDeployment></PropertyGroup></Project>
============================================================================================================================
I am running below command to publish my web site to Azure, using this profile.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin>msbuild C:\XXX\WebApplication1\WebSite1 /p:DeployOnBuild=True /p:PublishProfile=C:\XXX\WebApplication1\WebSite1\App_Data\PublishProfiles\SampleWebSite1-WebDeploy.pubxml
But if fails with below error.
============================================================================================================================
AspNetPreCompile:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /WebSite1 -p C:\Users\XXX\AppData\Local\Temp\WebSitePublish\WebSite1-934461955\obj\Debug\AspnetCompileMerge\Source -c C:\Users\XXX\AppData\Local\Temp\WebSite
Publish\WebSite1-934461955\obj\Debug\AspnetCompileMerge\TempBuildDir
c:\Users\XXX\AppData\Local\Temp\WebSitePublish\WebSite1-934461955\obj\Debug\AspnetCompileMerge\Source\Default.aspx.cs(7): error CS0234: The type or namespace name 'Claims' does not exist in the namespace 'System.Security'
(are you m
issing an assembly reference?) [C:\XXX\WebApplication1\WebSite1\website.publishproj]
Done Building Project "C:\XXX\WebApplication1\WebSite1\website.publishproj" (default targets) -- FAILED.
Build FAILED.
"C:\XXX\WebApplication1\WebSite1\website.publishproj" (default target) (1) ->
(AspNetPreCompile target) ->
c:\Users\XXX\AppData\Local\Temp\WebSitePublish\WebSite1-934461955\obj\Debug\AspnetCompileMerge\Source\Default.aspx.cs(7): error CS0234: The type or namespace name 'Claims' does not exist in the namespace
'System.Security' (are you
missing an assembly reference?) [C:\XXX\WebApplication1\WebSite1\website.publishproj]
0 Warning(s)
1 Error(s)
============================================================================================================================
While publishing, I need to keep these two options in my profile, to precompile files so that it does not publish actual code files (.cs) and it excludes web.config file from publishing.
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<ExcludeFilesFromDeployment>web.config</ExcludeFilesFromDeployment>
If I remove any of these option, it correctly publishes site on Azure.
But the issue is happening because of having both options together.
If I keep <PrecompileBeforePublish>True</PrecompileBeforePublish>, it always fails with the error “error CS0234: The type or namespace name 'Claims' does not exist in the namespace 'System.Security'
(are you
missing an assembly reference?) [C:\XXX\WebApplication1\WebSite1\website.publishproj]”
I tried various options but could not make this working.
So can someone help me to publish this sample web application, to Azure, using given command, with both the options <PrecompileBeforePublish>True</PrecompileBeforePublish> and <ExcludeFilesFromDeployment>web.config</ExcludeFilesFromDeployment>.