"The specified path, file name, or both are too long" while archiving Xamarin builds in Archive Manager

If you have a long default path, you're going to inevitable hit this error while archiving your Xamarin builds:

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Actually, your app have already been archived.

Simply close the Archive Manager. And then open it again at Tools > Archive Manager.

Now you can Distribute it like usual.


And if you're using Windows 10 Anniversary Update, it does not hurt to enable long path inside Windows.

  1. Press Windows key + R to open the Run dialog. Type gpedit.msc.
  2. Navigate to: Computer Configuration > Administrative Templates > System > Filesystem
  3. Double click on "Enable Win32 long paths". Enable it.
    1. Alternatively, if you don't see this option click on NTFS > Enable NTFS long path.
  4. Restart Visual Studio 2017. Done!


.NET Core Token Auth


However, by default if you do unauthorized request you'll be redirected to /account/login. Whereas for REST API you want to return 401 not authorized instead.

So, you do something like this:

options.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents
   OnRedirectToLogin = ctx =>
       if (ctx.Request.Path.StartsWithSegments("/api") &&
           ctx.Response.StatusCode == (int) HttpStatusCode.OK)
           ctx.Response.StatusCode = (int) HttpStatusCode.Unauthorized;
       return Task.FromResult(0);

Ref: https://devblog.dymel.pl/2016/07/07/return-401-unauthorized-from-asp-net-core-api/



Android Lifecycle