Showing posts with label iis. Show all posts
Showing posts with label iis. Show all posts

Tuesday, May 31, 2022

Build and deploy .net framework / .net core to IIS with Gitlab and some awesome templates

In this blog I'll explain the way we do our builds with gitlab. It took some time to get to this, so I'm happy to share it with you. At first we set the ground-rules:
  1. You use GitLab
  2. You have GitLab runners on windows machines on powershell (core)
  3. Make use of merge requests to merge code changes to the default branch
  4. Create release tags in the form of semver '1.0.0'
  5. The default branch always gets deployed to your development IIS server
  6. After creating a release in GitLab, a production build is generated
  7. Manual trigger starts the deployment to your production IIS server
  8. There is a solution file in the root of the project
  9. There is only 1 deployable webproject in your solution
  10. The dotnet-* templates reside in a shared repository
Challenges we faced we're especially with the msdeploy command which behaves really funky under powershell (I dare you to do a duckduckgo search on this and see what you'll find). I really like the way everything is parameterized, so the core just works, but if you need a bit more, you just adjust where needed without breaking all the defaults in the build an deploy pipelines. This makes maintaining them a lot easier when environments change and forces you to use a standardized way of work. 

I also like the validation of the release tag numbering using the .pre step validate_tag job. It only runs when a tag is set and it's not in the form of a semver. You can never build a production packages without a proper number.

The .gitlab.yml is the ci file for your end project, it sets urls and can customize some configuration. The dotnet-framework.v1.gitlab-ci.yml and dotnet-core.v1.gitlab-ci.yml files are the base templates you can inherit in the .gitlab-ci.yml. 

Below are all the gists needed to get you going or just to get inspired. If you have any feedback, I'm happy to learn about your experiences. Comment on the gist or this blog!

Happy deploying,
Luuk

Wednesday, September 7, 2011

Automatic deploy multiple websites in a solution using TFS Continious build

On the internet are a lot of resources to be found to automatically deploy websites to your (development) webserver. Here's how I solved that problem:

First of all, make sure your Team Foundation Server Continious build is up and running, and building packages the way you configured is.
Second of all, make sure you can deploy your website using the single click publish using MsDeploy.
Now edit the project file of the project(s) you would like to deploy and add the following tags in the PropertyGroup element:
<DeployTarget>MsDeployPublish</DeployTarget>
<CreatePackageOnPublish>false</CreatePackageOnPublish>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<MSDeployServiceUrl>https://yourwebserver:8172/MsDeploy.axd</MSDeployServiceUrl>
<UserName>YOURDOMAIN\User</UserName>
<Password>yourpassword</Password>
<AllowUntrustedCertificate>true</AllowUntrustedCertificate>
In the PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " element add the application path. By doing this, we can deploy different configuration types to app paths. If you need for example also a different username and password, you can add them in this section too.
<DeployIisAppPath>websites/Website</DeployIisAppPath>
Once we've edited the projects as mentioned above, we can setup the Build:

Voila! You're finished! Now build and watch your site change!

Save the build configuration and start a new build. If everything is correct, the website will be deployed on each build! For references you can look at the site of Vishal Joshi:
http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html
http://vishaljoshi.blogspot.com/2009/11/web-deployment-painkillers-vs-2010-ms.html

and stack overflow:
http://stackoverflow.com/questions/2878385/how-do-you-deploy-a-website-and-database-project-using-tfs-2010

Tuesday, September 6, 2011

WCF using svc files in IIS and the maximum message size quota exceeded error

When using WCF you can (and will ;) ) run into the following exception when posting messages:
The maximum message size quota for incoming messages (65536) has been exceeded.
Normally you can easily edit the config files and bind the right endpoint to the right bindingconfiguration and it workt. But how can you do that when using wcf by calling svc files hosted on an IIS server which have no endpoint configured. I've been struggling with this for hours and I can finally give you the answer! You'll have to match the service name with the full classname (including) namespace. After that you can setup the max length and for example ssl (https support). MailService.svc.cs:
namespace SC.MessageGateway.WcfService
{
    public class MailService : IMailService
    {
        // ...
    }
}
Web.Config:
<system.serviceModel>
    <services>
        <service name="SC.MessageGateway.WcfService.MailService">
            <endpoint address=""
                      binding="basicHttpBinding"
                      bindingConfiguration="LargeMessageSizeAndHttps"
                      contract="SC.MessageGateway.Communication.ServiceContracts.IMailService" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <bindings>
        <basicHttpBinding>
            <binding name="LargeMessageSizeAndHttps" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <!-- Enable Https -->
                <security mode="Transport">
                    <message clientCredentialType="Certificate"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
</system.serviceModel>
This answer was found with the help of Ladislav Mrnka's response in:
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/a7ebf86b-7d47-43c8-84d0-f8be17d42ab9/