I can't create an Azure backend template VS 2019 - asp.net

I'm following this tutorial https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter1/firstapp_pc/ and at some point it creates an ASP.NET project and loads and Azure Mobile App template.
When I redo these steps in my VS2019 I don't have the option of Azure Mobile App (I have Azure installed). The options are, Empty, Web Forms, MVC, Web API and Single Page Application
There is a backend example that can be downloaded here https://github.com/Azure/azure-mobile-apps-quickstarts/pull/126. However, if I do that my project and solution already have a name I don't want and it's tedious to change and easy to make mistakes.

Try this
create function .csproj file manual using below content
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
save this file as myfunction.csproj.
right click solution and choose add existing project and choose project created in step 2
now u can start working on this by adding references and function code.

Related

MSbuild Website Not Publishing to Local Directory

I need to publish a .NET web site project to a local directory. The web site project is part of a solution that also contains a web app. The Publish Web App option in Visual Studio publishes the web site to the directory without issue, however I am unable to publish the site through msbuild.
My msbuild command
msbuild "C:\...\ProjectName\website.publishproj" /p:deployOnBuild=true /p:publishProfile=Dev /p:PrecompileBeforePublish=false /p:VisualStudioVersion=14.0 /p:WebPublishMethod=FileSystem
The dev.pubxml publish profile I am referencing is:
<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>True</ExcludeApp_Data>
<publishUrl>C:\FolderLocation</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeFoldersFromDeployment>.vs</ExcludeFoldersFromDeployment>
</PropertyGroup>
</Project>
Currently the web site is not publishing to C:\FolderLocation but instead appears to publish to ProjectName\PrecompiledWeb\localhost_51636. Changing the output directory via /p:OutDir=C:\FolderLocation publishes the web app to the correct location, however it does not publish the web site. I have also tried both /p:PublishDestination and /p:DesktopBuildPackageLocation msbuild arguments however the original issue remains.
I have referenced Publish Artifacts for website goes to PrecompiledWeb and many other resources. My eventual goal is to setup CI through Azure Devops for the entire legacy .NET website project.
With TFS - it is using MSBUILD under the covers and we need this parameter to write to a directory for artifacts to be pulled from
/p:OutDir=$(build.StagingDirectory)
You are telling it only about the Publish Project part - see if putting your SLN file there at the first parameter solves it and does all of them.

asp.net core 2.1.0 Publish customised identity UI views

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>

How to get ASP.NET MVC Publish to copy over a native binary to the bin dir

I have created an ASP.NET MVC 4 website in VS 2013. One of the library assemblies I depend on wraps a native dll. I copy that native DLL to the project's output dir in the project's post-build event. That allows me to run the website under IIS Express and that works fine. However, when I go to Publish the site the native DLL gets left in the dirt. Ideally I want either the Win32 or x64 native dll published depending on what platform is currently selected in Visual Studio. Anybody know how to get native DLLs to be scooped up by the Publish command?
BTW I've tried the trick where you "add link" the DLL to the project and set the Build Action to None and set the "Copy to Output Directory" to Copy Always. While that works, it only works for one particular bitness of the native dll. That is less than ideal.
You can add conditions to the .csproj (or .vbproj) file by editing it by hand.
Save any work in the project.
Right-click the project node in solution explorer, and click Unload Project.
The whole project will collapse into a single node. Right click that node and select Edit <Project Name>.csproj (or .vbproj).
Scroll down and look for your DLL that you used for. It should look something like:
<ItemGroup>
<Content Include="bin\Release\x86\My.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Duplicate it and add a condition. In this case, you want to change it based on platform. Here is one way to do that. Do note that you should analyze the project file to determine the best condition to add for your particular configuration. You should also change the directory to match the (relative) location of your 32 and 64 bit DLL files.
<ItemGroup Condition=" '$(PlatformTarget)' == 'x86' ">
<Content Include="bin\$(Configuration)\x86\My.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition=" '$(PlatformTarget)' == 'x64' ">
<Content Include="bin\$(Configuration)\x64\My.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Visual Studio doesn't display this correctly (it will show a broken DLL link and a valid DLL link), but rest assured this method functions. It also helps to understand that a Visual Studio project file is nothing more than an MSBuild configuration file. So, although Visual Studio doesn't support a way to add or display conditions or some other MSBuild options, they all will function correctly if configured according to the MSBuild documentation.
You need to include the dll in your project and then once it is there right click on the dll, select Properties, and then make sure "Copy to Output Directory" is set to "Copy Always"

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