Sunday, 21 July 2019

csc.exe error - The specified task executable location "projectlocation\packages\Microsoft.Net.Compilers.1.0.0\build\..\tools\csc.exe" is invalid

I created a branch in my system from vsts and now i am facing issue with csc.exe error. The error is following-

The specified task executable location "E:\ProjectLocation\packages\Microsoft.Net.Compilers.1.0.0\build\..\tools\csc.exe" is invalid.

I wondered that last time this project was running in my machine and when i took this code from vsts now getting this error. I checked many solutions in internet but there was no luck to running my application. 

Later i checked about this csc.exe file and i found its available in following location.

C:\Users\manoj\Documents\Visual Studio 2017\Projects\WebApplication1\packages\Microsoft.Net.Compilers.1.3.2\tools

Now i again check my problem and i found that visual studio is looking for csc.exe file and this file should inside E:\ProjectLocation\packages\Microsoft.Net.Compilers.1.0.0\build\..\tools folder location.

So I just copied tools folder (which contains csc.exe file and other executable files) from C:\Users\manoj\Documents\Visual Studio 2017\Projects\WebApplication1\packages\Microsoft.Net.Compilers.1.3.2\tools location and copied in my error location i.e. E:\ProjectLocation\packages\Microsoft.Net.Compilers.1.0.0\build\..\tools location. 

Wow now my problem is fix and i am able to run my web application. Following csc.exe file is getting add in Micsosoft.Net.Compliers..../tools folder.




If the same error of csc.exe is invalid error comes in vsts pipeline build.


Commit the source code now after build in vsts branch.
Now try to build the solution. csc.exe related error will be fix in pipeline build also.


Friday, 19 July 2019

Redirection of website from its domain to domain with some string in MVC or Asp.net


Routing is used to create custom routing. Custom routing like url of as we want.

Here I am talking about Redirection of website along with some string in its URL.

I have a website like mydomain.com and i would like to redirect it in mydomain.com/abc or /mystring url.

This can easliy done with Custom routing in route.config file in MVC like 


routes.MapRoute(
                name: "Default",
                url: "mystring/{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

            );

The above syntax for routing is creating route as -

mydomain.com/mystring

now if we try mydomain.com then server will not found index url and will throw mydomain.com redirected you too many times error.

The second main thing is add a httpRedirect tag either in IIS setting or in web.config file. If in IIS httpRedirect tag is not available then go to IIS setting and enable it.

Now need to change in web.config file in <system.webServer> tag and add below syntax.

<httpRedirect childOnly="true" destination="/mystring" enabled="true"></httpRedirect>

ChildOnly attribute should be true. In destination need to provide the string which we want to redirect.

Now the site will redirect automatically from mydomain.com to mydomain.com/mystring.