Identity works fine on localhost but having errors on server - asp.net-core

I am using .Net Core MVC with built-in authorization for individual user accounts.
Registration and login works fine when I run it locally but when I uploaded it on Smarterasp and tried to register I got an error saying :
An error occurred while processing your request.
This is my publishing profile
<?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>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>website.com</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ProjectGuid>501f4fbc-faa5-4f41-859b-177881cbb611</ProjectGuid>
<SelfContained>false</SelfContained>
<MSDeployServiceURL>https://website.com:8172/MsDeploy.axd?site=coinmaniabot-001-site1</MSDeployServiceURL>
<DeployIisAppPath>sitename</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>False</EnableMSDeployBackup>
<UserName>coinmaniabot-001</UserName>
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
<_SavePWD>False</_SavePWD>
</PropertyGroup>
</Project>

Related

how to change default siteName and its physical path using msdeploy

Here i'm trying to automate publish the package for a web application to publish IIS on a remote server.
Following things are done to make the package.
Publish.proj.xml file:
<Project ToolsVersion="4.0" DefaultTargets="Publish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectSolutionFile>Test.sln</ProjectSolutionFile>
<Configuration>Release</Configuration>
</PropertyGroup>
<ItemGroup>
<ProjectToBuild Include="$(ProjectSolutionFile)">
<Properties>DeployOnBuild=true;Configuration=$(Configuration)</Properties>
</ProjectToBuild>
</ItemGroup>
<Target Name="Publish">
<MSBuild Projects="#(ProjectToBuild)"/>
</Target>
</Project>
If i pass this Publish.proj.xml file to msbuild. it'll build the solution and will create the package with below included things,
1. PackageTmp (folder)
2. Test.deploy.cmd
3. Test.deploy.SetParameters.xml
4. Test.SourceManifest.xml
5. Test.zip
Test.SetParameters.xml
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="Default Web Site/Test_deploy" />
</parameters>
Test.SourceManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
<IisApp path="C:\Release\Package\PackageTmp" managedRuntimeVersion="v4.0" />
<setAcl path="C:\Release\Package\PackageTmp" setAclResourceType="Directory" />
<setAcl path="C:\Release\Package\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>
Now, i'm trying to install this package in a remote server to publish the package using below command,
SalesCatalogue.deploy.cmd /y /M:https://RemoteServer:8172/MSDeploy.axd /u:"Test" /p:Test123 -allowUntrusted /A:basic
It has created new virtual directory in IIS under Default Web Site->Test_deploy and package files are deployed in C:\inetpub\wwwroot\Test_deploy folder.
My requirement is, Virtual directory name, applicatio Pool, destination physical deployment path are should be configurable. So that I can provide name whatever for virtual directory, can select desire application pool and can deploy in different path if required.
How can i achieve this? Any one can suggest me.
Thanks in advance.

VSTS msbuild: How to use parameters instead of profile? Error: Could not find __.dll

I have a simple "Hello World" mvc web application that I am attempting to build in VSTS. My steps are:
Get Sources
Run msbuild on a single project
Publish artifact (publish directory)
Everything works fine whenever I use a profile for msbuild, but I would like to just pass the parameter commands in instead. When I do this I get the following error:
Error : Copying file bin\WebApp01.dll to obj\Release\Package\PackageTmp\bin\WebApp01.dll failed. Could not find file 'bin\WebApp01.dll'.
What mistake am I making with my msbuild parameters? How do I properly duplicate a simple file system profile?
Parameters (error'ing):
/p:DeployOnBuild=true /p:Configuration="Release" /p:Platform="Any CPU" /t:WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl=PublishToOctopus
Profile (works):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>PublishToOctopus</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
When using /p:DeployOnBuild=true, you can use the normal Build target. You directly called WebPublish (/t:WebPublish) which expects a build to already have happened but since it doesn't, the file is missing from the expected location.

Execute .bat file at end of VS2017 Asp.Net Core publish action?

In Visual Studio 2017 when publishing an Asp.Net Core Website using the File System publish method I want to trigger the execution of a .bat file after the publish operation copied the files to the output directory.
I have learned that the settings for the publish operation are stored by Visual Studio in the project's Properties/PublishProviles directory in a .pubxml file. So in may case the file is FolderProfile.pubxml and it currently looks like this:
<?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>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<PublishFramework>net461</PublishFramework>
<ProjectGuid>f58b5ca0-8221-4c97-aa6d-7fba93a3abeb</ProjectGuid>
<publishUrl>C:\inetpub\wwwGiftOasisResponsivePublished</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
Based on the comments in the .pubxml file and additional research, it's my understanding this file is essentially an msbuild file and ultimately msbuild is used to perform the publish operation. msbuild files seem very flexible but more than a little complicated. I'm really struggling with this one.
If I had a batch file in the root of my project called finishPub.bat, how could I modify the above .pubxml file to cause the execute of the finishPub.bat file after the website has been copied to the output folder?
You can amend your publish profile with a custom target:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
...
</PropertyGroup>
<Target Name="ExecuteBatAfterPublish" AfterTargets="AfterPublish">
<Exec Command="example.bat" WorkingDirectory="$(publishUrl)" />
</Target>
</Project>

MS Web Deploy creating new folder under Web Site?

I am using the post here to deploy MVC5 application to IIS 8. In IIS i have a web site "Default Web Site" which is pointed to physical location "C:\Inetpub\wwwroot\mywebsite"
My build file look like below
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<ProjectFile Condition=" '$(ProjectFile)' == '' ">.\UI\$(ProjectName)\$(ProjectName).csproj</ProjectFile>
<DeployServiceUrl Condition=" '$(DeployServiceUrl)' == '' ">http://localhost</DeployServiceUrl>
</PropertyGroup>
<Target Name="VerifyProperties">
<!-- Verify that we have values for all required properties -->
<Error Condition=" '$(ProjectName)' == '' " Text="ProjectName is required." />
</Target>
<Target Name="Build" DependsOnTargets="VerifyProperties">
<!-- Deploy using windows authentication -->
<MSBuild Projects="$(ProjectFile)"
Properties="Configuration=$(Configuration);
MvcBuildViews=False;
DeployOnBuild=true;
DeployTarget=MSDeployPublish;
CreatePackageOnPublish=True;
AllowUntrustedCertificate=True;
MSDeployPublishMethod=RemoteAgent;
MsDeployServiceUrl=$(DeployServiceUrl);
SkipExtraFilesOnServer=True;
UserName=;
Password=;"
ContinueOnError="false" />
</Target>
</Project>
I'm running the following command to build & deploy
msbuild build.xml /p:Configuration=Release;ProjectName=MyProjectName;DeployServiceUrl=http://localhost
The command builds the project and deploys the project. However it is not deploying the project directly under "Default Web Site" instead its creating a new application under "Default Web Site" with the name "MyProjectName_deploy" and this application is pointing to new physical location. "C:\inetpub\wwwroot\mywebsite\MyProjectName_deploy"
I want the code to deploy directly to C:\inetpub\wwwroot\mywebsite where "Default Web Site" is pointing.
Add the following to your build file:
<PropertyGroup>
<DeployIisAppPath>Default Web Site</DeployIisAppPath>
</PropertyGroup>
Related details -
https://dotnetcatch.com/2016/03/03/simple-service-versioning-with-webdeploy/

Ajax Minifier to Deploy Package .zip

I'm using AjaxMin to minify my .js and .css files this is configured within my Release.pubxml file and it works fine as when I navigate to the Release/Package/PackageTemp folder the .js and .css have been minified correctly.
However when I navigate to the actual Package .zip file the .js and .css files have not been minified they are just the original files. I assume that the files in my PackageTemp are not replacing the Package deploy files and I'm not sure how to achieve this from within my .pubxml file. My .pubxml file currently looks this this:
<?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 http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>Package</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<DesktopBuildPackageLocation>C:\Documents\TestDeploy</DesktopBuildPackageLocation>
<PackageAsSingleFile>true</PackageAsSingleFile>
<DeployIisAppPath />
<PublishDatabaseSettings>
<Objects xmlns="" />
</PublishDatabaseSettings>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMin.targets" />
<PropertyGroup>
<OnAfterPackageUsingManifest>
$(OnAfterPackageUsingManifest); Minify;
</OnAfterPackageUsingManifest>
</PropertyGroup>
<Target Name="Minify" AfterTargets="CopyAllFilesToSingleFolderForPackage">
<ItemGroup>
<JS Include="$(_PackageTempDir)\**\*.js" Exclude="$(_PackageTempDir)\**\*.min.js;" />
<CSS Include="$(_PackageTempDir)\**\*.css" Exclude="$(_PackageTempDir)\**\*.min.css" />
</ItemGroup>
<Message Text="**************MINIFYING**************" Importance="high"></Message>
<AjaxMin JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js" CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css" />
</Target>
<PropertyGroup>
<ExcludeFoldersFromDeployment>bin</ExcludeFoldersFromDeployment>
</PropertyGroup>
</Project>
Please could someone shed some light on how to replace the files in my deploy .zip file with the PackageTemp Files via my .pubxml file
Thanks
My error i just noticed i was using the OnAfterPackageUsingManifest option. For anyone that also faces this issue try using the OnBeforePackageUsingManifest option instead.