Can monodevelop do Web.config transformations like no VS2010 - asp.net

It's very important to have Web.config transformations when we want to avoid errors while publishing for staging or production. Can this be done using monodevelop? I've search for a solution without any success.

I'm answering after a long time in case someone finds this question.
I have developed a way to publish a ASP.NET project through xbuild (not directly through Monodevelop) with Web.config transformations.
You can find it here.

Not currently (as of 2.10.9). Mono does not yet have an implementation of MSDeploy, and specifically the Microsoft.Web.Publishing.Tasks.dll assembly and the Microsoft.Web.Publishing.targets file.

You can use the MSBuild.Microsoft.VisualStudio.Web.targets NuGet package , see TransformXml task fails via msbuild on linux using mono for full instructions.

Related

problems setting up aspnetcore-angular2-universal example seed

We are for some time now trying to find a solution for server prerendering of SPA, specifically Angular4, for the purpose of SEO.
We have come to try and use aspnetcore-angular2-universal, which seems to be the perfect solution, however, we encounter problems deploying the published build to a local IIS server.
We have posted an issue regarding the problem on the issues page at which can be found here:
https://github.com/MarkPieszak/aspnetcore-angular2-universal/issues/491
We have followed the instruction under "Getting started" & "Deploy" (which can be found here: https://github.com/MarkPieszak/aspnetcore-angular2-universal) exactly but the error still exist.
The support is unresponsive on issues and thus we are posting also here.
The problem is (as mention in the issue linked here) that we get the following error:
Which indicates a problem with the web.config file. However the webconfig file is exactly as supplied in the starter project and seems also legit.
I should mention that building and running the project using npm build:prod and dotnet run works and we can lunch an in memory application from Visual Studio Code, however when taking the published folder to an IIS folder the error occurs.
Any help will be appreciated.
Did you installed .NET Core Windows Server Hosting bundle?
Check if AspNetCoreModule listed in IIS => Modules. Sometimes it not installed properly during #1, even if there was "Succeeded" at all steps. In that case I just removing it via Program & Features, and reinstalling it then.
Once I saw that error when manually copied web.config from sources over the publish folder. Problem is that original web.config contains placeholders like %LAUNCHER_PATH% and %LAUNCHER_ARGS%, which turns to appropriate values (dotnet and .\YourApp.dll for instance) during dotnet publish
Aperantly there were incompebilities between angular5 & universal in serverside.
The https://github.com/MarkPieszak/aspnetcore-angular2-universal seed was downgraded to using angular4.3 instead of 5. When we updated seed, the problem was solved.

How can I add an assembly binding redirect to a .net core unit test project?

I'm trying to create a .net core unit test project against framework 4.6.1 which tests an project dependent on Microsoft.SqlServer.Types (10.0.0.0). Prior to .net core I'd add an app.config file with the binding redirect. I've tried this but the binding redirect does not seem to be picked up when I run from visual studio. What can I do to fix the binding redirect?
If you reference Microsoft.NET.Test.Sdk >= 15.3.0 in your project it automatically turns on the required MSBuild properties, as Fabian says below. See here.
You can add the following settings to your .csproj file:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Otherwise adding them to an app.config in the root of the solution, as Joao says, works too. Make sure you set its Copy to Output Directory setting to Copy always or Copy if Newer.
Referencing the NuGet package Microsoft.NET.Test.Sdk >= 15.3.0 (I used Microsoft.NET.Test.Sdk 15.3.0-preview-20170601-03) solved this problem for me. That package automatically turns on the MSBuild properties mentioned in #Mardoxx's answer.
(I got this info from Martin Andreas Ullrich at https://github.com/NuGet/Home/issues/5335#issuecomment-306318810.)
In my case none of the solutions mentioned above helped (even if the binding redirects are generated automatically or added manually, looks like these hacks are really not working anymore as #Joao suggested).
So I added the desired version of the package to my project, even if it is not used directly and this resolved the issue. I don't like this approach, but this was the only way working for me.
Hopefully this method can help others as well.

MSBuild: Web application, build once package and deploy many

I'm sure this question has come up before, but I can't seem to find an elegant solution.
I have a web application project with multiple configurations based on deployment environment (Test, QA, Production) along with web.config transforms for each environment. We are using a web deployment package to automatically create the .zip of the app which can be deployed via MSDeploy. It's easy enough to call the package target multiple times, each with a different configuration:
msbuild MyProject.csproj /t:Package /p:Configuration=QA
msbuild MyProject.csproj /t:Package /p:Configuration=Test
But this triggers a complete rebuild of the web project each time before packaging. I want to build once, then apply the web.config transforms, and create separate packages for each environment. Is there an easy way to accomplish this without forcing a complete rebuild for each environment?
Dupe of Build once and deploy to multiple environments with msdeploy & Visual Studio 2012
I've also been wanting a solution to this, but apparently there isn't any real COMPLETE MS solution that I know of. Visual Studio provides the following (as noted here):
Web.Config transformation
Parameterization
Vishal Joshi concluded with the following:
If you can know your environment settings during build time use
Web.Config transformation.
If you would want to create deployment package only once and then
enter the settings during install time then use Parameters.xml
What I would like to see, though, is have the best of both worlds. I want to "package" up a target having ALL the configuration transformations embedded. Therefore, when the IT guy runs the WebDeploy cmd file (that gets generated when you "package"), they can provide a switch of which environment configuration they want (i.e. Dev, Test, Stage, Prod, Release, etc). I don't believe there is a solution from MS out there that does that. :(

Don't see Clean solution option in Visual Studio

For one of the solutions, I don't see the Clean Solution option neither in the context menu when I right click on the solution name in the Solution Explorer nor in the Build menu. When I make any changes to the project and debug, VS never hits the break point and I get the "The breakpoint will not currently be hit. The source code is different from the original version." message. My understanding is that I need to clean the solution.
For other solutions, I do see the Clean solution and I don't have the same issue.
If you are using website project then their wont be clean solution option,it's available only with web application projects.
Finally had to create a brand new solution and add the projects from the older solution to the newly created one. Not sure what the problem was, but this helped.
I also faced the similar problem recently and this is what I came to.
I guess you are running an older code version than the one you want to debug on. Rebuild the project(s), paying attention to dependencies. Use the "Rebuild" feature.
If it's a Web application project, just clean it yourself by nuking all DLLs in the bin. Then rebuild. I assume it builds without errors?
If you're running a web site, as apposed to a web application project, you probably don't have an actual solution, or even a project file.
For a web site, you need to rebuild the website (from the build menu), or manually delete all of the dlls to accomplish the same thing.
Edit:
How are you debugging? Are you using Cassini (the built in visual studio debugger), or attaching to an IIS process?
I would also try this:
Go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and delete the folder that has the same name as your website.
I had the same problem. Visual Studio was building my old code with debug. I opened a new instance of Visual Studio and opened my solution with it and it now works fine. No idea what happened.
You can also clean using devenv /clean SolnConfigName SolutionName in the command line environment.
Here is the reference: http://msdn.microsoft.com/en-us/vstudio/aa718635.aspx
For a website solution, just clean your web browser history and the Cache there.

Could not load type MyNameSpace.PageName

I have switched to a new PC and got the latest version out of source safe but now when I do a ReBuild I get Could not load type then the name of my namespace.the name of my pages?
It seems ok if I do a Build.
Any ideas?
UPDATE: Once a Rebuild is done it removes the Namespace.dll and then doing a Build it fails with the same errors.
UPDATE 2: I think it has something to do with aspnet_compiler.exe? Do standard Web Applications run this after a build? I have setup another test Web Application and it runs Csc.exe but not aspnet_compiler.exe but I can't see anywhere in my project where its configured to run this.
maybe you have refferenced a DLL directly, instead of a project in a solution.
This could cause a rebuild to work
I've lost references before when I've moved to a new machine. So, I would start by checking the references on the projects with the errors.
I found in my csproj file the following:
<AspNetCompiler PhysicalPath="C:\Projects\MyProject" Debug="false" VirtualPath="/MyProject" />
Not sure what this is doing, I think it was put in there for some reason.

Resources