Publish once while using RCL(Razor Class Library) - asp.net-core

I used RCL to store the header and footer of my website and was referenced by several projects.
The projects referenced the RCL by the Project Reference of VS.
Every time I modify the RCL, I have to republish all the projects referenced it(By the web deploy). That's so troublesome.
Is there any way that only publishes once while I modify the RCL?
Thank you.

This is expected as the RCL is changed. You may need write some scripts to make it easy to publish the multiple projects after rebuilding the solution.
And you can also use any CI/CD tools for application lifecycle management, for example Azure DevOps.

Related

.Net Core - referencing another project in solution prevents System and other dependencies from being recognised

I have a solution that contains a number of projects, one is an API, the other is an admin portal.
I'm trying to create another project inside the solution to hold all shared components such as database entities so they can be shared between the API and the Admin Portal.
I've created a new project called 'Common' and selected to use netcoreapp2.2 because if I just select a standard class library then annotations on the Entities don't work.
When I reference the 'Common' project from the 'API' project, which is also netcoreapp2.2, Rider(Mac) is unable to recognise any of the standard packaged used with the project such as System and System.Linq (and many others).
My experience with .Net Core is limited to only this project, so I'm sure I'm doing something wrong, I just can't figure out what it is.
I managed to fix this, I removed the 'Common' project from my solution and re-created it this time selecting the create the project as a Web Application.

Only build if project or dependencies has changes in Azure devop

I have multiple projects in the same folder, each of them creates a microservice. Each has a separate build and release pipeline. Currently each project is configured so to trigger when code is committed in its own sub folder. I am currently in the process of adding some common code which is used in some of the projects. I would like for a microservice to build and deploy if it uses a library that is being changes.
What is the best way to achieve this?
Ideally, I imagine something like this:
Build task which triggers on root directory -> Use MsBuild to determine if a project needs to build, by checking its dependencies -> Build/Abort.
Is this possible?
If you want to share code in source form and you are using .NET Framework projects, the best (but not optimal) approach that I found is to have the projects in the same folder and put the shared code in a subfolder that you include in both projects. To put shared code in a folder outside the root folder of a project is even worse.
The best approach (IMO) is to share code in compiled (Dll) form (rather than in source form): you can create a DLL with the shared code, package it in a NuGet package, and publish the NuGet package in some internal NuGet repository (for example, you can use the Artifacts feature of Azure DevOps as NuGet repository for your organization). The projects that require the shared code do it through NuGet references. The advantages is that the shared code in Dll/NuGet form can be versioned (not all projects must be updated at the same time for incompatible changes), it can use its own CI pipeline with unit tests, it can use its CD pipeline to publish to the Artifacts repository, etc.
I switched from the former approach to the latter. Much cleaner IMO.

Migrate custom XAML build workflow to TFS 2017 extensions

I currently have a custom XAML build workflow which performs a lot of validations based on code structure, folders, file content and even database configuration.
Currently we need to consider to migrate it to TFS 2017, and I'm trying to understand the possibilities, effort and pitfalls and this is where I could use your help.
I have logic built in C# and then I look at MSDN documentation the language seems to be Javascript, GitHub samples seem to be Typescript. Am I forced to use one of this languages? any preferred one or limitations that I should be aware of? Can for instance, I connect to a database directly? or it's better to have an API and just use REST calls?
Can I for instance, use .Net object which have already some wrapped logic?
I also noticed that on the manifest file I can declare inputs, but can I somehow use outputs? For example, I have a task that does validation and in the end I would have a task to send an e-mail with the result of that validation. Is this possible?
Thank you in advance.
You are right in concluding that XAML builds are deprecated. The new Task based system is much more flexible and now that we even have YAML support, you can move to Builds as Code.
The reason you're seeing Build Tasks in TypeScript (which is a superset of JavaScript) because of the cross platform nature of NodeJS. This allows your tasks to run on Windows, Linux and Mac. In the mean time we also got .NET Core support. You can also use PowerShell if that's more of your liking.
Regarding your 'can I connect to a database' question. Yes you can, if you want it is another question. This will massively slow your build down and will make your build fail if there are issues with database connectivity. I would suggest asking a second question here on Stackoverflow to describe your situation and discuss if there is a better alternative.
You can use output variables from your task and reuse these in the next tasks. That's all supported and no problem (see https://roadtoalm.com/2016/08/11/set-output-variable-in-a-powershell-vsts-build-task/ for an example).
There are too many questions here and they are broad.
Whatever, XAML Build are deprecated in TFS 2017 and will not be available in the next version of TFS. VSTS already no longer supports them. So you need to Migrate from XAML builds to new builds (vNext builds). Also this similar thread for your reference : Converting TFS XAML Build Custom Activities into TFS 2015 Build Tasks
Marketplace
While you can make use of custom build tasks with XAML build there is
no centralized or integrated solution for browsing available tasks,
installing them or managing them. With the new builds you can make use
of the quickly-growing Visual Studio Team Services Marketplace. Here,
you can search and browse the many extensions currently available in
the Marketplace.
See WHY SHOULD I LEAVE XAML BUILDS for details.
So, you can find the existing extensions in Marketplace and install them to extend the build process (add correspinding tasks). You can also custom your own extension based on your specific requirements. See Extensions overview.
You can build custom applications or services that integrate with your
Visual Studio Team Services (VSTS) and Team Foundation Server (TFS)
accounts by using the REST APIs to make direct HTTP calls, or
utilize our .NET Client Libraries.
Source here : Integrating with VSTS and Team Foundation Server
To add a custom task you can reference below articles:
Add a build task
Reference for creating custom build tasks within extensions
Developing a Custom Build vNext Task
For the "outputs" validation, you can try it with build alerts.

ASP.NET 5 and Build Action

I have a Web Site and Class Library built with ASP.NET 5. The Class Library depends on an set of external files (XML, EXEs, etc.). Those dependencies are added as part of the project and visible in the Solution Explorer of Visual Studio.
My Web Site has a dependency on the Class Library. When I build the Web Site, I would expect the dependencies of the Class Library to be copied to the Web Site, but they aren't.
The Build Action (Copy always, Copy if changed) appears to be gone with ASP.NET 5. How do I make sure that dependencies other then the DLL of the Class Library itself gets copied to the Web Site project?
First thing first, they won't be in src/yourProject/bin/Debug. Those have been moved to the artifacts folder.
Also, your project by default will not output DLLs. This is mainly due to performance reason but if you need your DLL to publish your application, check your project properties. In the Build section you should have an option called Produce outputs on build. Tick that and bingo.
You have your dlls. Most of the time (aka: while coding), you won't need them since they will always be recompiled in memory.
You need to manually add a pre/post build step in project.json

Web site to dll

I need to compile my web site, is it possible without converting to a web project first?
I think he wants to "protect" his code for any deployment.
If this is a .Net project you can try hide some code using codebehind components in ASP.NET.
Here is an small tutorial about it:
http://asp.net-tutorials.com/basics/code-behind/
For older projects you may have to build a cgi binary application, but as already mentioned here, add some more details to specify your problem.
I think you want a VS Web Deployment project. This exists as a separate project in your solution but can compile and copy the existing web project to a different directory.
There's a reasonable write-up of it on this blog with step-by-step instructions. You'll need to download and install the new project type separately though (2008, 2010)