Cake.IIS icon indicating copy to clipboard operation
Cake.IIS copied to clipboard

Could not load file or assembly error on build server

Open gswartz777 opened this issue 6 years ago • 0 comments

We use teamcity for our build server and I'm taking over a project for a developer who is no longer with us. He wrote a build.cake file to push our sites to our servers along with some other things. I have no experience with this and need to update it to also start and stop a site and application when the site is pushed. In googling it I came across this repository. I have updated our build.cake file with the following.

Task("deploy_live_websites")
    	.IsDependentOn("use_live_config")
    	.Does(() => 
    	{ 
    		foreach (var site in websites){
    			foreach (var server in liveServers){
    				CreatePool(server, new ApplicationPoolSettings()
    				{
    					Name = site.ApplicationPoolName,
    					Username = devWebDeployUser,
    					Password = devWebDeployPassword
    				});
    				CreateWebsite(server, new WebsiteSettings()
    				{
    					Name = site.SiteName,
    					Binding = IISBindings.Http
    								.SetHostName(site.HostName)
    								.SetIpAddress("*")
    								.SetPort(80),
    					PhysicalDirectory = site.PhysicalDirectory,
    					ApplicationPool = new ApplicationPoolSettings()
    					{
    						Name = site.ApplicationPoolName
    					}
    				});
    
    				StopSite(server, site.SiteName);
    				StopPool(site.ApplicationPoolName);
    
    				DeployWebsite(new DeploySettings()
    				{					
    					SourcePath = "./artifacts/_PublishedWebsites/" + site.Name + "/",
    					ComputerName = server,
    					SiteName = site.SiteName,
    					Username = webDeployUser,
    					Password = webDeployPassword
    				});
    
    				StartPool(site.ApplicationPoolName);
    				StartSite(site.SiteName);
    			}			
    		}
    	});

Specifically the update I made was the StopSite, StopPool, StartPool, StarSite lines.

When I push this to our build server it fails when this executes. The error I get is

    [20:29:19][Step 1/1] ========================================
    [20:29:19][Step 1/1] deploy_live_websites
    [20:29:19][Step 1/1] ========================================
    [20:29:19][Step 1/1] Executing task: deploy_live_websites
    [20:29:19][Step 1/1] Application pool 'TECWare_v4' is system's default.
    [20:29:19][Step 1/1] An error occurred when executing task 'deploy_live_websites'.
    [20:29:19][Step 1/1] Error: One or more errors occurred.
    [20:29:19][Step 1/1] 	Could not load file or assembly 'System.Diagnostics.TraceSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
    [20:29:19][Step 1/1] Process exited with code 1
    [20:29:05][Step 1/1] Process exited with code 1
    [20:29:19][Step 1/1] Step PowerShell failed

I have no idea what the issue is. Anyone have an idea on how to fix this? It worked fine before adding the start/stop methods. Also I added #addin "Cake.IIS" to the top of the file.

gswartz777 avatar Sep 14 '18 12:09 gswartz777