Deployment hell, Microsoft.Web.Infrastructure.dll - asp.net

We have to deploy our web project on several (possible 10) servers , We've developed Nant script that doing the Job , but We've face with problem , that Microsoft.Web.Infrastructure.dll that is one of the dependencies doesn't deployed what ever we do.
Could anyone please explain how can add reference to this dll , and mark it copy local or something ? I'll try to explain what's hapening , when I am adding reference to this dll to our proj , the reference added to web.config like :
<assemblies>
<add assembly .... blah blah />
</assemblies>
This means that assembly should be in GAC , right ? I can see it well if I am clicking on Property Pages in visual studio , and going to refereces tab , I can see that this Dll is in Gac.
Ok , the following command
gacutil.exe -l Microsoft.Web.Infrastructure returns with no Result !
So where is this assembly stored ? How the magic is done by Microsoft ???
How can I remove it from GAC ???
Anyone ?
PS. One of the possible resolutions that I've found on web. Is to run Package Manager and install it from there again ... but for me it's not a options , we aren't connected to internet for security reasons.

If you've developed against MVC assuming its installed in the GAC why don't you just install it on the target server via http://www.asp.net/mvc/mvc3
The copy local solution is great if you've got a proj file to work with but you don't as you opted for a website project which is all sln and web.config.
You could add a reference via your websites property page (from your nuget package)
You sound like you already have nuget package but if not you just right click on the bin folder and manage packages - Microsoft.Web.Infrastructure - install
If you add this package reference to your bin folder you'll see a new file:
bin\Microsoft.Web.Infrastructure.dll.refresh
This just contains a link to actual dll in the package - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
The dll will get copied over to the bin folder at build time.

I would suggest you use webmatrix / web platform installer to install the DLL on each of the servers.

Related

System.Threading.Tasks.Extensions unloaded by IIS

I have a project with assembly which refers to System.Threading.Tasks.Extensions, Version=4.6.28619, It's an old ASP.NET App hosted on IIS. After compilation, the app is running and everything is OK. After some time, the app throws an exception.
"System.Exception: Could not load file or assembly
'System.Threading.Tasks.Extensions, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51.
After the recompilation and restarting the APP, everything works fine, but after a few hours, the exception is thrown again. What could be the problem?
I have tried to change web.config to use System.Threading.Tasks.Extensions in the correct version, but it didn't help.
Version=4.6.28619 is file version, not the Assembly Version. I did goodle on System.Threading.Tasks.Extensions history.
I found the 4.3.0 should be the correct version in your project.
Other version couldn't find 4.1.0.0 version dll like picture above. Package version >=4.4.0, using 4.1.1.0. <4.3.0, using 4.0.0.0.
Now you can follow the suggestions below to check the issue
Find the package System.Threading.Tasks.Extensions like my first picture.
If you have multi project, make sure all the projects using the same version package.
Delete the .vs folder
Check the web.confg/app.config file, and check the version of System.Threading.Tasks.Extensions, if there are duplicates, please delete them.
If the steps above not works for you, maybe the issue related to deployment. You can try the binding redirects.

VIsual Studio 2017 NuGet package installs well but is not recognized

I have Solution A which has a .NET Core 1.1 class library project. In the Package properties I filled all NuGet fields and selected to create the NuGet upon successful build. This project builds just fine and the NUPKG is created. BTW How can I automatically copy the generated NUPKG to a local directory (my own repository)?
Then I have Solution B which is an ASP.NET Core 1.1 web application. In it I browse to my local repository (where I have manually copied the NUPKG built by Solution A) and install my SolutionA.MyPackage into the web application. VS.2017 says it was successful at installing it. I see it listed in the project's NuGet dependencies.
However, when I try to use ANY of the objects defined in that NuGet package I get a red highlight saying it is not found as if there was no NuGet or assembly reference to that DLL but there is!
What is causing this Visual Studio generated Nuget package to be installed and yet act as if it has not even been referenced?
UPDATE - CSPROJ TARGET
As for copying to my local repository, I added this to CSPROJ but it was not working (somebody had suggested it as I put it). I finally figured out why it did not work, the ItemGroup must be inside the Task.
<Target Name="CopyPackage" AfterTargets="GenerateNuspec">
<ItemGroup>
<MyPackageFiles Include="bin\Release\PackageId.*.nupkg" />
</ItemGroup>
<Copy SourceFiles="#(MyPackageFiles)" DestinationFolder="D:\My Repository\MyNugget\Publish" />
</Target>
UPDATE NuGet Inspection
I opened the NUPKG with NuGet Package Explorer and it shows this more or less:
content\
Properties\
launchSettings.json
Views\
Shared\
rest of my stuff here
contentFiles\
any\
netcoreapp1.1\
Properties\
launchSettings.json
Views\
Shared\
rest of my stuff here
lib\
netcoreapp1.1 (.NEtCoreApp, Version=v1.1)
MyPackage.dll
UPDATE 3
Since NuGet seems to have stopped working (used to work well earlier) I opted for using an Assembly Reference rather than a NuGet (for now). In this situation something odd happens, when coding I can reference ALL the objects in the referenced assembly (former NuGet) and therefore no compilation errors on the main project BUT when I then run the web application I get an internal error because it says
FileNotFoundException: Could not load file or assembly
'MyPackage, Version=0.0.3.0, Culture=neutral, PublicKeyToken=null'.
The system cannot find the file specified.
Unknown location
Which is strange because in the Solution Explorer I see the assembly reference and when I click on it (main application) I can navigate to all the objects that I have defined in that assembly. Why it cannot find it anymore?
It is working again (as it was before!). Today I could open the solutions but when I tried to download an extension (Tools | Extensions) I got an error message about an Access Denied or something like that. It has happened before since I installed to VS.2017.
Of all the Visual Studios I have used since 2002 this has been the most unstable! (and I have update 15.2).
When I saw this error happening again I knew how to get rid of it and thought, "hey, maybe that is what is keeping the NuGet package to be installed but not found or the problem with a direct assembly reference".
So I went to my C:\Users\AppData\USER\Local\Microsoft\VisualStudio\15.2* folder and removed it completely.
After that I the ACCESS DENIED issue went away with the side effect that I had to reinstall all extensions again. I attempted again to install my own NuGet, it did so successfully and as expected (was not happening during the long glitch) the objects were found and the web application worked again.

Why doesn't my .tfignore file ignore my packages folder

I am using Visual Studio 2013 Pro and Team Foundation Server 2013. I have a .tfignore file with the following lines:
\packages
\<project name>\Bin
!\<project name>\Bin\*.refresh
Line 1 is not working but lines 2 and 3 are. The project name above is a website inside a solution. There is nothing else in this solution. There are nuget packages installed which automatically pull down when you publish or build the website. When that happens this package folder is created in the solution. It's not added to the solution explorer, it's just in the same folder as the solution when you look at the filer in file explorer.
Please let me know if there is any other information you need.
You can control this in NuGet.config.
Make sure the key "disableSourceControlIntegration" exists and is set to "true":
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
References:
http://docs.nuget.org/docs/Reference/Package-Restore
http://docs.nuget.org/docs/Reference/NuGet-Config-Settings
If your packages are already in TFS, you should first "undo pending changes" on your local, delete them from TFS Source files and then, check in In Visual Studio. That will removed the packages from the server and will not ask to check them in again.

"Can't find the valid AspnetMergePath" on Visual Web Developer Publish?

I am wanting to use Visual Web Developer Express 2010 to publish a website, pre-compiled to a remote server over FTP using the following settings:
Deploy only files needed to run this application
Precompile this application before publishing
Allow website to be updatable
No databases are being deployed
Site is being deployed as file hierarchy, not as .zip package
My first build/deploy seemed to have gone well, but after my second compilation I receive the following error:
Transformed web.config using C:\path_to_site\Web.Debug.config into obj\Debug\TransformWebConfig\transformed\web.config.
Copying all files to temporary location below for package/publish:
obj\Debug\AspnetCompileMerge\Source.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets(132,5): Error : Can't find the valid AspnetMergePath
And here's a subset of the content of the Microsoft.Web.Publishing.AspNetConfigurationMerge.targets file:
<Target
Name="GetAspNetMergePath"
DependsOnTargets="$(GetAspNetMergePathDependsOn)"
Condition ="'$(GetAspNetMergePath)' != 'false'">
<PropertyGroup>
<AspnetMergeName>aspnet_merge.exe</AspnetMergeName>
<AspnetMergePath Condition="Exists('$(TargetFrameworkSDKToolsDirectory)$(AspnetMergeName)')">$(TargetFrameworkSDKToolsDirectory)</AspnetMergePath>
</PropertyGroup>
<Error Condition="'$(AspnetMergePath)' == '' Or !Exists($(AspnetMergePath))"
Text="Can't find the valid AspnetMergePath" />
</Target>
EDIT: Changing the publish settings to delete all existing files before publishing does not fix the problem after all. I'm assuming that the problem is local for now because of this.
There does not appear to be an AspMergePath tag in my web.config. I am not aware if I am supposed to manually add the tag. However, the path "obj{publish setting}\AspnetCompileMerge\Source" does exist in my project.
And in case it matters, my project name is "TestProject.NET"
Your feedback is appreciated.
I hit the same problem. Searched through all microsoft related sites, found a lot of complaints and no intention from microsoft to fix it.
Here how I worked it around at my system. Edit the Microsoft.Web.Publishing.AspNetConfigurationMerge.targets file and add the following line. Please make sure that the Microsoft SDK path is the same on your PC, if not then change it:
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\</TargetFrameworkSDKToolsDirectory>
Here is how it should look like:
<Target
Name="GetAspNetMergePath"
DependsOnTargets="$(GetAspNetMergePathDependsOn)"
Condition ="'$(GetAspNetMergePath)' != 'false'">
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\</TargetFrameworkSDKToolsDirectory>
<AspnetMergeName>aspnet_merge.exe</AspnetMergeName>
<AspnetMergePath Condition="Exists('$(TargetFrameworkSDKToolsDirectory)$(AspnetMergeName)')">$(TargetFrameworkSDKToolsDirectory)</AspnetMergePath>
</PropertyGroup>
<Error Condition="'$(AspnetMergePath)' == '' Or !Exists($(AspnetMergePath))"
Text="Can't find the valid AspnetMergePath" />
What you need is aspnet_merge.exe, tool that is distributed as part of Windows SDK. It's intended to precompile sites, so you can either turn that precompilation off, or install proper version of Windows SDK. Reference is to the Wikipedia, because of nice prepared links to the download pages. You don't need to download/install everything (it's huge), just download web installer and select .Net tools, it will take around 50 megabytes.
Please, notice that bundled with Visual Studio 2010 Windows SDK ver. 7.0A isn't available to separate download, so you'll have to either install Visual Studio on your build server, or tweak something as described in answers to "Running MSBuild fails to read SDKToolsPath".
Here is a solution that does not require changing the targets file. The workaround from http://connect.microsoft.com/VisualStudio/feedback/details/786492/publish-cant-find-the-valid-aspnetmergepath suggests passing additional properteries to msbuild. I was able to get it to work using this:
msbuild website.publishproj /p:DeployOnBuild=true /p:PublishProfile=Release /p:VisualStudioVersion=12.0 /p:AspnetMergePath="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\"
The key here is the AspnetMergePath property, which you may need to change if the Windows SDK is installed in a different location. If I include the GetAspNetMergePath property from the workaround it fails, but that may be needed depending on the SDK version.
One workaround for all this stuff [including having to install the SDK etc] is to disable the Precompile On Publish option, which requires AspNetMerge to be present even if you're not specifying that you want stuff to be merged in the ultimate output.
I was going to great lengths to figure out how to turn it off, poring over the options dialog and Reading the Friendly Manual to confirm I had it turned off for ages only to realize it was the checkbox outside:
Unchecking yields the following changes to the .pubxml:
- <PrecompileBeforePublish>True</PrecompileBeforePublish>
- <EnableUpdateable>True</EnableUpdateable>
- <DebugSymbols>False</DebugSymbols>
- <WDPMergeOption>DonotMerge</WDPMergeOption>
Which worked for me.
NB it is however critical to have as covered here both the Web (which will silently make publishing via /p:DeployOnBuild inert) and the WebApplications (which will give a compiler error) subfolders present under %Program Files (x86)%\MSBuild\Microsoft\VisualStudio\v14.0 (assuming Visual Studio 2015 tooling) for publishing to successfully generate packages
I hit the same problem.
Edit the Microsoft.Web.Publishing.AspNetConfigurationMerge.targets file and add the following line. Make sure run editor with Administrator Rights.
Looks the correct versiĆ³n Visual Studio in my case VS2013.
x64
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\</TargetFrameworkSDKToolsDirectory>
x86
<TargetFrameworkSDKToolsDirectory>C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\</TargetFrameworkSDKToolsDirectory>
And it Works! I can compile my Project.
In my case was missing. It happened after updating Visual Studio 2017 to 15.7.5. Before that it was working fine. I have to add
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\</TargetFrameworkSDKToolsDirectory>
It was at Line no 129 in Microsoft.Web.Publishing.AspNetCompileMerge.targets
change targetFramework ...
<compilation debug="true" targetFramework="4.8"/>
<httpRuntime targetFramework="4.8"/>

Mono's XSP webserver can't find MySql.Web.dll on Linux

I'm working on getting my ASP.Net project working on Linux. I've been testing my code using XSP on windows, but now I am trying to make sure that I can develop and test on Linux as well. To that end I've gotten Ubuntu running and have MonoDevelop and MySQL running. I've downloaded the latest MySQL Connector/Net and I think I have it installed correctly.
There is no package that will automatically install the MySQL Connector/Net for distribution so I downloaded the 6.2.3 zip file from the MySQL website. Now I've already discovered the issue with case sensitivity because the zip file contains filenames in lowercase, and Mono expects them in uppercase. So I've changed the names of the files to MySql.Data.dll, and MySql.Web.dll respectively. I've also used gacutil to install both files to the GAC. Likewise I have added the files to the Mono Lib directory. The following files do exist on my machine:
/usr/lib/mono/gac/MySql.Data/6.2.3.0__c5687fc88969c44d/MySql.Data.dll
/usr/lib/mono/gac/MySql.Web/6.2.3.0__c5687fc88969c44d/MySql.Web.dll
/usr/lib/mono/2.0/MySql.Data.dll
/usr/lib/mono/2.0/MySql.Web.dll
I've also created package files so that I can add references to the the assemblies in MonoDevelop. The folder /usr/lib/mono/2.0 contains two .pc files that I added.
MySql.Web.pc:
Name: MySql.Web
Description: ASP Membership, Role and Profile providers powered by MySQL
Version: 6.2.3
Libs: -r:/usr/lib/mono/gac/MySql.Web/6.2.3.0__c5687fc88969c44d/MySql.Web.dll
MySql.Data.pc:
Name: MySql.Data
Description: Provides connectivity to MySQL databases
Version: 6.2.3
Libs: -r:/usr/lib/mono/gac/MySql.Data/6.2.3.0__c5687fc88969c44d/MySql.Data.dll
At this point I can use the assemblies in projects inside MonoDevelop. The Assemblies appear in the list of available assemblies when I edit the project references. The project now compiles without error inside MonoDevelop. However when I run the compiled web project in XSP the following error is displayed in the browser:
System.IO.FileNotFoundException: Could not load file or assembly 'MySql.Web.dll, Version=6.2.3.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D' or one of its dependencies. The system cannot find the file specified.
What is fustrating is that originally the error was that it could not load MySql.Data.dll and now the error message is that it can not load MySql.Web.dll. Which means that I somehow fixed the problem I was having with the Data dll, and now I have the problem with the Web dll. I have gone and re-done I learned to fix the problem for the Data dll, but I am unable to get the Web dll working.
Unfortunately I'm still pretty new to Linux and Mono (but not to ASP.Net) and I've run out of things to try. Likewise I haven't found anything on Google to try other than what has been described above which leaves me asking for help.
Can anyone help me find out why XSP can't find the assembly and what I can do about it?
Thanks,
-Will
You can try setting some environment variables which should tell you where all Mono is looking for assemblies:
MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" xsp2
Not a perfect fix (I don't know why its going wrong), but if you're in a hurry, copy MySql.Web.dll to the bin directory of your app.

Resources