I installed WIF runtime and SDK on my machine. I added Microsoft.IdentityModel.dll to my azure web application and locally everything is running great. I build simple web application which use Azure AppFabric Access control. I follow azure labs for that and as I told, local everything is great. When I published my web application to Azure, I'm getting following error :
Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I get it after Appfabric Relaying part is going to return url, after sign in on identity provider. The weird thing is that I set Copy Local to TRUE, because that .dll is not part of Azure GAC. I tried to publish it again, but I received same error. I found few same problems on the internet but with no concrete solution. Does anybody here had something similar and probably have a working solution? Thank you in advance
For anything that I need to deploy locally to Azure I make a copy of the DLL's in my project folder and reference them from there while setting copy local to true. Since doing this I no longer have any issues with DLL's not being published to Azure. I also do all of my building through the command line using MSBuild and publish the cspack by hand. This means that I do not rely on Visual Studio for doing the build or deployment.
I have run into this and solution described in this blog helped. You will need to run this command from your role startup task:
gacutil /nologo /i .\Microsoft.IdentityModel.dll
This startup task has to be run with full privilegies.
Have you tried disabling encryption on the creation of the deployment package and verifying that the dll is indeed present?
Create a new environment variable called: _CSPACK_FORCE_NOENCRYPT_ set the value to true.Restart your visual studio.
Related
I wanted to publish my project in Azure Devops pipeline but I encountered several errors.
I tried to publish one of the .csproj file of my solution (.sln) from VisualStudio2017 it worked perfectly but when I try it with Azure Devops pipeline then it shows the below error. I've googled everywhere but not able to find the correct solution to solve my error.
My pipeline looks like this
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\Node.js Tools\Microsoft.NodejsTools.targets(201,5): Error : web.config not found in project, to create a project to deploy to Microsoft Azure you must create an Azure Node.js project. Process 'msbuild.exe' exited with code '1'
Tried adding the basic web.config file even that doesn't work.
Building and Publishing on Azure Devops Failed
To resolve this issue, you can try a quick way to solve it is by creating a Blank Azure Node.js Web Application and copy-paste the web.config into your project.
Check more details on section "Converting to an Azure project type" of page: https://github.com/Microsoft/nodejstools/wiki/Publish-to-Azure-Website-using-Web-Deploy:
The easiest way to get them is to create a new temporary Azure project
type, such as:
Blank Azure Node.js Web Application Basic Azure Node.js Express
Application Starter Azure Node.js Express Application Basic Azure
Node.js Express 4 Application And copy the missing web.config and bin
folder from the new project to your existing project.
Note that in web.config, the starter .js file (app.js, server.js or
something else) appears a few times. Make sure that it matches your
starter file, otherwise your application won't run properly when it's
deployed on Azure.
Hope this helps.
Try to delete delete and create a new solution or override the existing solution.
Then build it locally and then, check-in & build in azure CI pipeline.
It worked for me hope it works for you too.
I have a ASP.NET Core app. I run the application by running the command
dotnet run
I'm seeing the following error in one out of five situations when I build this ASP.NET Core app.
C:...\error CS2012: Cannot open 'C:...\bin\Debug\netcoreapp1.0\AAA.Web.dll' for writing -- 'The process cannot access the file 'C:...\bin\Debug\netcoreapp1.0\AAA.Web.dll' because it is being used by another process.'
In addition to the above issue, I also see no updates that I make in the CSHTML file. I have to stop the dotnet run command, build the app again and then run the dotnet run command.
How can I fix these issues?
This may also help when running your aspnetcore app in IIS.
Add the following to your csproj:
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="echo "App Offline" /a > "$(ProjectDir)app_offline.htm"" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="del "$(ProjectDir)app_offline.htm"" />
</Target>
If it is on local and application is running on IIS, then in windows task bar before your date time, there should be a IIS Express Option. select IIS Express, select exit. Try running application again.
In my case, I got the same issue due to dotnet watch run command even after stopping the watch mode. Visual studio reported this error message :
The file is locked by: ".NET core Host (pid)"
killing the process with the pid fixed the issue.
When trying to kill the process using /taskkill /f /pid <number in the error> it was telling me the process didn't even exist.
I simply had to find .NET Core Host in Task Manager and end it there.
This occasionally occurs when I edit a test project on Core 3.0 - not using IIS, it's a class library and a test project in a solution only.
Open the Task Manager, find .NET Core Host, right-click, end task.
The dotnet watch command can track file system changes and edits and compile them in to the running process. This is done by first installing the Microsoft.DotNet.Watcher.Tools package in the tools section of the project.json file. See documentation of its usage here.
Once it is installed, you can then run the app with the command dotnet watch run and make edits while avoiding the manual restarting of the application.
I ended up recycling the Application Pool to get my dlls unlocked.
This has happened to me many times. The issue, at least in my case, has been that I have the application running. So when the compiler tries to update the dll it can't because the dll is locked and in use by the running application. Once I close the application and do the compile again, it works fine.
I may be a bit late to the party here, but for future people reading this question, it would appear that this is a bit of a 'feature' with how VS/core is able to interact with IIS and stop files from being locked:
https://developercommunity.visualstudio.com/content/problem/546858/bin-files-locked-by-iis-worker-process-1.html
It is apparently being investigated and looked into for .net core vnext.
I'm still running into this regularly in VS2017 and VS2019. Hopefully this helps someone.
This is what works every time for me.
If using IISExpress - Stop the Application using the icon in the task bar (near the clock/time)
If using IIS - Stop and Restart the site
OR
In an Admin command prompt run taskkill -F -IM node.exe (Kills all node processes currently running)
100% Working For Me
it is being used by another process .net core
go to task manager (for windows )
Right click .NET Core Host
click End Task
as like see this image
This problem offen when you set AspNetCoreHostingModel to "OutOfProcess"
then you have two solution for problem:
change hosting model to "InProcess"
use below command in CMD
taskkill /f /pid {.netcore hosting pid , show you in error line in visual studio}
For use that command, you do not use "" and {}.
For me, it worked by -
Go to your bin and the environment, take a backup for files, try deleting the folder
D:\CawProjects\EmailAnalytics\APIV1\APIV1\bin\Development
if it does not allow you to delete and says Open/Used somewhere then follow the below process.
Open task manager - find for .net core host and right-click to end the task
I have create a sample ASP.NET 5 application (pretty much the example one from New Solution), and pushed it to GIT hosted on Visual Studio Team Services (former Visual Studio Online). I want to set up continuous integration to Azure Web App (former Azure Web Site). I have tried to set it up from Azure portal itself, it did create a new build definition, but it fails to build ASP.NET 5. I have found a guide how to do this, but it never really worked for me, I get errors like this e.g.
Error parsing solution file at C:\a\1\s\Frontend\src\Frontend\Frontend.xproj: Exception has been thrown by the target of an invocation.
Predefined type 'System.Void' is not defined or imported
Another problem is that it seems it really takes a lot of time to install dnvm, get packages, etc. So all in all it's a pain to make it work.
So are there real alternatives for that or more importantly is Microsoft is planning to implement something like a Build ASP.NET 5, Deploy ASP.NET to Azure and such to make it easy as I suppose it's easy with the current ASP.NET 4 apps. I really hope that it will be an option soon since it's quite impossible to work with current build system.
For "System.Void" issue, please check the runtime version in "global.json" file and make sure it is consistent with the dependencies in "project.json" file.
For dnvm install issue, since AspNet5 runtime environment isn't installed on VSTS Hosted Build Agent for now and the different users may use different runtime versions, it requires the user to add a "PreBuild" PowerShell step to read the runtime version in "global.json" file and then install it. If you can make sure that you will always only use one version (For example: 1.0.0-rc1-update1), you can deploy your own build agent and install "1.0.0-rc1-update1" on it, then you can skip the dnvm installation during the build process.
Take a look on http://riffer.eu/wordpress/?p=112. There I have a solution vor asp.net core RC_1.
Amazingly you need only two powershell scripts - there is no compiling / visual studio necessary.
We have with success been updating our development web site at a daily basis using msdeploy from TFS2010.
This was working fine until we upgraded to VS2012, our application from .NET Framework 4.0 to 4.5 and ASP.NET MVC from 3.0 to 4.0. It look like all is well and assemblies deployed but nothing has actually been deployed.
I have been looking into this for two days now and can't figure out why this is happening and now I am running out of ideas.
Below is part of my build script in the way it has been working before the upgrade.
<MSBuild
Projects="$(SolutionRoot)\My.Web\My.Web.csproj"
Properties="MvcBuildViews=False;AllowUntrustedCertificate=True;AuthType=Basic;Configuration=Dev;CreatePackageOnPublish=True;DeployIisAppPath=dev.myweb;DeployOnBuild=True;DeployTarget=MsDeployPublish;MSDeployPublishMethod=WMSvc;MsDeployServiceUrl=https://10.xxx.xxx.xxx:8172/MsDeploy.axd;UserName=UserName;Password=Password;UseMsdeployExe=True"
ContinueOnError="False"
/>
When the upgrade was initiated and my problem discovered we were using Web Deploy 2.0 but now we have upgraded to Web Deploy 3.0. I have also made sure we are building with ToolsVersion="4.0".
UPDATE --
msbuild.exe /p:AllowUntrustedCertificate=True
/p:AuthType=Basic
/p:Configuration=Dev
/p:CreatePackageOnPublish=True
/p:DeployIisAppPath=dev.myweb
/p:DeployOnBuild=True
/p:DeployTarget=MsDeployPublish
/p:MSDeployPublishMethod=WMSvc
/p:MsDeployServiceUrl=https://10.xxx.xxx.xxx:8172/MsDeploy.axd
/p:UserName=UserName
/p:Password=Password
/p:UseMsdeployExe=True
E:\Builds\1\WhatEver\Daily_Build\Sources\My.Web\My.Web.csproj
Now I also tried to run the above msbuild command from our TFS and no response which frustrates me completely. Nothing in the event log of TFS, nothing in log file no matter verbosity... Any ideas?
It does work using msdeploy directy like below;
<Exec Command=""C:\Program Files\IIS\Microsoft Web Deploy V3\MSDeploy.exe" -verb:sync -source:contentPath="E:\Builds\1\WhatEver\Daily_Build\Sources\My.Web\My.Web.csproj" -dest:contentPath="E:\dev.my.web",computername=https://10.xxx.xxx.xxx:8172/MsDeploy.axd,username=UserName,password=Password,authtype=Basic -allowUntrusted=True"
ContinueOnError="false" />
--
UPDATE 2 --
It appears Microsoft added a check for what type of projects that are publishable projects and our web application are not, since the Output Type is Class Library. This has been valid with v4.0 but apparently not for v4.5.
Anyone have an idea of what to do make it work again? Do I need to change the project type? Create publishing package up front and then deploy that? Or what?
--
Anyone else that has had the same problem? Have you found a solution to share?
Could there be an issue with version of MSBuild?
Here is what I would recommend. In VS2012 we have made it easy to automate publishing your web projects using the publish profiles which are created by the publish dialog. In your case create a new MSDeploy profile. When you create that profile we will save the settings into a file under Properties\PublishProfiles (or My Project\PublishProfiles for VB). The extension of this file will be .pubxml. Those files are actually MSBuild files, which you can customize if needed. You can continue to use the publish dialog as well. The password will be stored in a .user file and encrypted such that only you can decrypt it.
After you have created that profile you can publish with the command below if you are building the .sln file.
msbuild mysoln.sln /p:DeployOnBuild=true /p:PublishProfile=<ProfileName> /p:Password=<Password>
If you are building the .csproj/.vbproj then you need to tweak this a bit in the following way
msbuild mysoln.sln /p:DeployOnBuild=true /p:PublishProfile=<ProfileName> /p:Password=<Password> /p:VisualStudioVersion=11.0
More on why VisualStudioVersion is required at http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx.
Once you do this you will be able to build+publish just like you did previously. FYI we have shipped all these new web publish features for VS2010 in the Azure SDK https://www.windowsazure.com/en-us/develop/net/#.
Also in your question I noticed that you are specifying some custom properties, like MvcBuildViews. You can now place those properties directly inside the publish profile (the .pubxml file) if you want. Of course you can still pass them in on the command line if that makes more sense for your scenario.
More info on this at http://sedodream.com/2012/06/15/VisualStudio2010WebPublishUpdates.aspx.
If you take a look at the approach that we had for developers to automate publishing it was to specify properties and targets to be executed during the build. The problem with this approach is that this limits our ability to enhance the web publish experience. In the new release we have introduced an abstraction, the publish profile, which allows us to change the underlying targets of the web publish pipeline and your automation scripts will continue to run. Hopefully from this point forward you will not have to re-visit this issue.
I had much the same problem today. I too was trying to get a .NET 4.5 web application automatically deployed using a machine that did not have Visual Studio 2012 installed on it. There were a couple of minor differences in my situation, however: I was using TeamCity instead of TFS, and our solution was created with .NET 4.5 as opposed to being one that had been upgraded from .NET 4.0.
Nonetheless, I did have the same problem described. I'd use MSBuild to build the web app and deploy it to IIS, in much the same way. This approach worked fine on my dev machine. However, when I ran MSBuild on the CI server, it quite happily built the web app, but it stopped after that: no errors, no warnings, nothing, just a message that the build was successful. There wasn't the slightest hint of an attempt at deploying the app to IIS.
It seems MSBuild was missing the relevant targets to perform the web deployment.
The fix was to copy the folder C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web from my dev machine to the CI server, copying it to the same place on the CI server as it was on my machine.
Once I did that, MSBuild then grumbled about needing Web Deploy 3.0, but that was fixed easily enough. After installing that on the CI server too, MSBuild quite happily deployed the web app.
To extend Luke Woodward's answer:
I, too, found that deploying C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\ from my local machine to the build server was the fix.
However, the real fix is to install the Microsoft Web Developer Tools as part of the VS 2012 installation, which will create this folder, among other things. This addresses Ieppie's licensing objection.
I tested this by...
Deleting C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\
Running the VS 2012 installer and adding MS Web Dev tools.
Verifying that, after the install, C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\ was back.
I'm trying to get my web application to deploy automatically at the end of an automated build and I'm obviously missing something.
My setup is:
VS2012 on a Win7 workstation
TFS2010 repository on serverA
TFS build agent on serverB
Test site in IIS7 on serverC.
I have created a quick test project using the default MVC4 template and created a Team Project to go with it using the MS VS Scrum 1.0 template.
I created a new publish profile for the web application using the publish web dialog and the .pubxml file is checked in with the project. The .pubxml file looks something like this:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<SiteUrlToLaunchAfterPublish>TestServer/DeployTest</SiteUrlToLaunchAfterPublish>
<MSDeployServiceURL>http://TestServer</MSDeployServiceURL>
<DeployIisAppPath>webapp-dev/DeployTest</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
<MSDeployPublishMethod>RemoteAgent</MSDeployPublishMethod>
<UserName>mydomain\myuser</UserName>
<_SavePWD>True</_SavePWD>
<PublishDatabaseSettings>
<Objects xmlns="" />
</PublishDatabaseSettings>
</PropertyGroup>
</Project>
*some of the names have been changed to protect the innocent :)
Using this profile I can successfully publish the application from Visual Studio to the test web server without any issue. Following Scott Hanselman's blog post I successfully published from the command line on my workstation:
msbuild DeployTest.csproj /p:DeployOnBuild=true /p:PublishProfile=Test /p:AllowUntrustedCertificate=true /p:Password=notTheRealPassword
I then created a build in Team Explorer that would use my build server to compile and then run the unit tests. All good. The project builds, unit tests pass.
I then added the parameters from the command line to the MS Build Arguments in the Advanced section of the build definition:
/p:DeployOnBuild=true /p:PublishProfile=Test /p:AllowUntrustedCertificate=true /p:Password=notTheRealPassword
The build runs, the unit tests pass, nothing is published to the web server. :(
Can someone enlighten me as to what I have missed? Nothing I've read seems to indicate a step I have missed out but there's seemingly precious little documentation to explain how this is done.
It sounds like tfs might not support publish profiles.
You may need to pull out all the parameters from the profile and specify them manually.
Here's a similar question.
Team Build: Publish locally using MSDeploy
I know this is an old question but today I ran into the same issue and I think I know the reason for the behavior you observed. Let me summarize the issue:
You have create a web deploy publish profile.
When you use the profile from command prompt with MSBuild command, the site is published successfully.
But when you use this profile from the build definition (by specifying MS Build Arguments in the advanced section of the build definition) the site is not published.
I think the reason behind this is because you have VS 2012 on your workstation which supports publish using profile feature. Hence when you run the MS build from command prompt on your work-station the site is published. But the support for publish profile is not available on TFS 2010 hence with build server the site is not published.
I faced the same issue today and I did following to resolve the issue:
On TFS machine, from the command prompt, I ran the MS Build command with publish profile. The command ran successfully but nothing got published (copied) on the site. This proves that TFS 2010 server does not support public profiles.
I had VS 2010 deployed on the TFS machine. I installed web deploy 3.5 and Windows Azure SDK for Visual Studio 2010. This is the way to provide support for publish profile on VS 2010.
Then I ran the MS Build command using published profile from command prompt and it published the site successfully.
Then finally executed the build definition with MS Build parameters and the site got published successfully.
I know installing Visual studio on TFS machine not an ideal solution but at least it solved my problem.
I am also not sure why installing VS 2010 with publish profile support resolved the issue. But it seems that, after the installation some of the missing components/dlls got deployed on the TFS machine which resolved the issue.
Hope this resolves your deployment issue.
[UPDATE]: There could be another reason for the above behavior. Check the log messages of the build activity. If you find a warning similar to this:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (484, 9): warning: The OutputPath property is not set for project ProjectName.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Release' Platform='Any CPU'
Then it may be related to build configuration. If you are using “Any CPU” as build configuration then change it to “AnyCPU” (remove space). Refer following link for the detailed explanation:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/0bb277ec-a08c-4795-88f0-3207654e2560/the-outputpath-property-is-not-set-for-project-xxxxxbtproj-please-check-to-make-sure-that-you?forum=tfsbuild
Amey