asp.net core 2.1.0 Publish customised identity UI views - web-deployment

Customised Identity UI razor pages not being deployed to server when publishing to IIS using Web Deploy.
Is there any specific configuration I need to add to use ?
According to Docs is already included in in .csproj file.

I had a similar issue and I noticed that in the csproj file I had
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
Which was needed in 2.0. I simply removed it in 2.1 and it worked.
Perhaps you can give that a try

I have added these lines to my .csproj and fixed it. more info is in this answer
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
</PropertyGroup>

Related

Which SignalR package to install for a .NET 6 server project?

I have a NET6 project which is built part of a larger .NET 6 ASP.NET solution. The project still references:
Microsoft.AspNetCore.SignalR, and
Microsoft.AspNetCore.SignalR.Core
Which have now been marked as deprecated.
What packages do I need to install for their replacement?
The problem is that currently SignalR is located in an assembly separate from the main ASP.NET project. This is because the main project and a couple of other projects within the solution use the hubs (using constructor DI).
If I change the SignalR project to
<Project Sdk="Microsoft.NET.Sdk.Web">
...
</Project>
I get the following compilation error:
Error CS5001 Program does not contain a static 'Main' method suitable for an entry point
So the problem is that I cannot have a common assembly with SignalR referenced by multiple other projects.
SignalR is included in the Microsoft.AspNetCore.App shared framework (docs). Change the console app SDK to Microsoft.NET.Sdk.Web:
<Project Sdk="Microsoft.NET.Sdk.Web">
...
</Project>
To use the ASP.NET Core shared framework in a class library project - add FrameworkReference element for Microsoft.AspNetCore.App:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Server-side SignalR is nowadays a part of the NET base class library. You don't need any server-side packages. The Microsoft.AspNetCore.SignalR namespace classes are just there.
However, you need the client-side package, the #microsoft/signalr#latest.
In case of further issues, please consult the documentation.

Different installation for bootstrap.sass nuget package for ASP.Net Core and Full framework projects

When i create an empty ASP.NET Web Application (.NET Framework) project with VS 2017 and install the bootstrap.saas nuget package (https://www.nuget.org/packages/bootstrap.sass), the package integrates within the project structure and the Content and Scripts folders are being created.
As the folders are within the project folder, i can easily work with them like compile them and minify them and copy the results into my wwwroot folder.
But when i create an empty ASP.NET Web Application (.NET Core) project with VS 2017 and install the bootstrap.saas nuget package, the package lands in the global nuget cache in the C:\Users\USER_NAME.nuget\packages\bootstrap.sass\4.0.0-alpha6\content folder and not in the project folder.
What is the best workflow/practice here to work with the nuget cache files and get them compiled and minified to the wwwroot folder within the .NET Core project?
Can i force nuget with an additional NuGet.Config file inside my project to install the package within my project folder or subfolder? Are there other options?
I know that i can use npm/webpack/gulp etc. for that but would like to do it the "old" way how Web Extension Pack did it for VS 2015 and like the Web Compiler (both from Mads Kristensen) do it now for VS 2017. Or do i run into a dead end using the Web Compiler?
Thanks
Can i force nuget with an additional NuGet.Config file inside my project to install the package within my project folder or subfolder? Are there other options?
If you want to change packages default location for .net core project, you can set "NUGET_PACKAGES" environment variable. Just Set "NUGET_PACKAGES" = "c:\teampackages". Or you can place a NuGet.Config file next to the solution with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value=".\packages" />
</config>
</configuration>
For the detail info, you can refer to this document and the same issue on GitHub.
However, what I want to say is that you might not be happy with the results.
Because .Net Core projects rely on so many NuGet packages. Almost hovering around 1GB. I think you will not want to set all those packages for each solution. Besides, with this change, you need to set up additional sources in VS for every solution. It`s quite inconvenient for .net core project.
This is the reason why NuGet team set the special settings for .net core projects. So how about add the Content and Scripts folders manually? It would not be very difficult.
Hope this can help you.

How to exclude web.config when publishing with Visual Studio 2013?

When using the "Publish Web Site" feature in Visual Studio 2013. How can you exclude publishing the web.config so that it doesn't overwrite the server web.config?
The question is identical to the following except the VS version.
How to exclude web.config when publishing with Visual Web Developer Express?
However, its solution does not apply to VS2013. "Build Action" option cannot be found in VS2013. And setting "ExcludeFilesFromDeployment" causes compile problems.
Simply select the web.config properties and change 'Build Action' to 'None' and 'Copy To Output Directory' to 'Do Not copy'
I know this is an old post, with old answers but to me, both described solutions are wrong.
Web.config flavors induces a security risk when manipulating environments credentials, and the "Build Action"="None" solution, breaks the possibility to debug the project locally,as the Web.Config file will never be present in the "bin" directory.
A cleaner solution is what is described here :
https://learn.microsoft.com/fr-fr/aspnet/web-forms/overview/deployment/advanced-enterprise-web-deployment/excluding-files-and-folders-from-deployment
which is basically to create a ProjectName.wpp.targets file, containing a list of files / folders to exclude when publishing your project.
To remove the Web.config from a project named Blog you would need to create a file named Blog.wpp.targets with something like this:
File: Blog.wpp.targets
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ExcludeFromPackageFiles Include=".\Web.config">
<FromTarget>Blog.wpp.targets</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>
</Project>
No need to change anything in your project or .csproj file.
Excluding the web.config file is not the recommended solution. You should use web.config transformation file instead, this is the web.xxx.config file.
When you publish your website, Visual Studio will merge your local web.config with the corresponding web.xxx.config file
The config transform file use XDT (XML Document Transform) syntax. For example, if you want to change your connectionstring, you can use this piece of code in you transformation file :
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB"
connectionString="value for the deployed Web.config file"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
See Web.config Transformation Syntax for Web Project Deployment Using Visual Studio for more examples and information.
If you're publishing to Azure App Services from Visual Studio (I'm using 2019), and didn't set the web.config's Build Action to 'none', you can do this every time:
Right click on your project, select publish. Then click on "Preview Changes".
Then un-check the web.config file so it does not get published. You'll get a chance to review what will be publish too.
I am doing this because I publish to multiple instances and each instances are of different version. This way I get to review the web.config everytime to make sure if there's any additional AppSettings configuration added, I will be aware of it.
For an legacy ASP.NET Web Application, add <ExcludeFilesFromDeployment>Web.config</ExcludeFilesFromDeployment> to the appropriate .xmlpub profile file found in the Properties\PublishProfiles folder.
<Project>
<PropertyGroup>
<ExcludeFilesFromDeployment>Web.config</ExcludeFilesFromDeployment>
</PropertyGroup>
</Project>
2020 and using AspCore project, then try to add below code in your .csproj:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
Refer to https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2#webconfig-file

Visual Studio .NET publish - How to run a command before "Publish" that generates code

I am using Visual Studio 2012 and am working with a JavaScript framework (Ext JS). My HomeController basically redirects to the index that Ext JS uses. It communicates with other Visual Studio projects that actually make use of .NET (via CORS), but this particular project just contains my JavaScript application.
I want to publish this Visual Studio project, but there is a catch. A tool that is used with Ext JS, named Sencha Command, is used to create a production version of the JavaScript application. It basically creates a stand-alone build folder that contains all the JavaScript scripts combined and minified, required resources, compiled Sass, etc. It works out really well in some scenarios, but I am not sure how to make it play nice with Visual Studio on publish.
I have figured out how to get the sencha command to run with a post-build command that checks to see if I am in debug mode or not, but I don't want the generated folder to be part of my actual project, and I don't want the not-yet-compiled code to be published either. I know how to omit a folder in my pubxbml file. But I need to do something like move the build folder to the publish location.
Has anyone encountered scenarios such as this? Is there a better way to go about this?
Here is my current pubxml:
<?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>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<publishUrl>C:\Users\TestUser\Desktop\Release</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeFoldersFromDeployment>
js/ext;js/App
</ExcludeFoldersFromDeployment>
</PropertyGroup>
<Target Name="BeforePublish" BeforeTargets="FileSystemPublish">
<Exec Command="echo Hello" />
</Target>
</Project>
Note: I don't think the BeforePublish worked. I tried a number of commands there, including the "sencha app build" command which I later moved to a post-build command.

Can TeamCity publish a Web project using the sln2008 build runner?

I'm building an ASP.Net MVC project in TeamCity.
Can I somehow call the Publish target and get the output copied to a folder under IIS? or do I need to write an msbuild script for this?
I've written a pretty long blog post on this very topic that may interest you:
http://www.diaryofaninja.com/blog/2010/05/09/automated-site-deployments-with-teamcity-deployment-projects-amp-svn
basically:
install web deployment projects
add web deployment project to your solution
setup the solution configuration manager to have a "Deployment" build configuration
get team city to use this build switch when running the build
have a beer and wonder in glory at your automagical awesomenesss
Have you tried a Web Deployment Project (WDP)? I have multiple Web Application Projects (WAP) with associated WDPs that work great with TeamCity for deployment scenarios.
I use the sln2008 runner to build my solution (containing both the WAP and the WDP). I've modified the WDP project file (an MSBuild script) to copy the output to a network share:
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Deploy' ">
<!-- copy WDP output to \\build02\wwwroot\Belden.Web.Intranet\ -->
<ItemGroup>
<MySourceFiles Include="$(OutputPath)**\*.*" />
</ItemGroup>
<Copy SourceFiles="#(MySourceFiles)" DestinationFiles="#(MySourceFiles->'\\build02\wwwroot\Belden.Web.Intranet\$(ProjectDir)%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
I haven't tried this with MVC/WDP, but I imagine it would work the same ...
I believe you can: Publish sln. Have a look at the targets. Hopefully it will lead you in the right direction.
I also had a look at this a while ago but could but had no luck with publishing targets, maybe because my IIS resided on a different server.
Here is how I did it anyway, hope it helps TeamCity deletes files on build have a look at the accepted answer.

Resources