Visual Studio Private gallery atom.xml throws error while accessing from visual studio - visual-studio-extensions

Error while Trying to create a private visual studio extension gallery.
I have a vsix file which is ready to be shipped to everyone in the organisation.I have generated the atom.xml(using openly available tools).
when i store the atom.xml file in my local machine and provide the local path in the extension in visual studio it works fine and i can see the extension in the visual studio.
But since the local path of my machine is not accessible to everyone in my organization i uploaded both Vsix and atom file into the git hub repository of the organisation.
When provided this git link where atom.xml resides it throws error as below
" For Security reasons DTD is prohibited in this XML document.To enable DTD proessing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method"
Intially thought this could be because of wrongly built xml. But the same XML does not create any problem when stored in local path and accessed through extensions gallery from visual studio
Already tried accessing the atom.xml file from local machine path and shows up no error. but when the same xml is uploaded to a organization git, it throws up the above error
Here is the atom.xml file through which i am trying to access the vsix file
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text"></title>
<id>86581393-7E84-4D3C-AB43-C519146CD947</id>
<updated>2019-09-26T11:29:40+05:30</updated>
<generator>VSGallery.AtomGenerator</generator>
<entry>
<id>cddba304-d16f-446e-b3a3-94d26d952189</id>
<title type="text">Trace</title>
<summary type="text">Visual Studio extension for Trace </summary>
<published>2019-09-25T06:11:31Z</published>
<updated>2019-09-25T06:11:31Z</updated>
<author>
<name>SJ</name>
</author>
<content type="application/octet-stream" src="https://github.xxx.com/Visual-Studio-extension/blob/master/trace.vsix" />
<Vsix xmlns="http://schemas.microsoft.com/developer/vsx-syndication-schema/2010" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
<Id>cddba304-d16f-446e-b3a3-94d26d952189</Id>
<Version>1.0.0.0</Version>
<References></References>
<Rating xsi:nil="true"></Rating>
<RatingCount xsi:nil="true"></RatingCount>
<DownloadCount xsi:nil="true"></DownloadCount>
</Vsix>
</entry>
</feed>
Here is the how i have added the private extension gallery in VS
This is the error which i receive when i try to access the extension

Related

app.config inside Visual Studio Extension?

I have created a Visual Studio extension representing a Visual Studio Project wizard (vsix package). I am attempting to wire up log4net, and this has been unsuccessful. I have chased the issue down to my app.config not being loaded properly.
I have added this to my app.config in my visual studio extension:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="test" value="hello world"/>
</appSettings>
</configuration>
and within my IWizard implementation, I have added this line of code:
var test = System.Configuration.ConfigurationManager.AppSettings["test"];
However, the test variable above is always null when debugging.
I have verified these things:
App.config is set to Build Action: Content
App.config is set to Copy to Output Directory: Copy Always
App.config is set to Include in VSIX: True
App.config file is present in my C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\16.0_...\Extensions\<Name>\<Company>\1.0 folder
What am I missing? And if App.config is not allowed within VSIX extension development, how would you go about wiring up log4net?
What am I missing? And if App.config is not allowed within VSIX
extension development, how would you go about wiring up log4net?
An App.Config file is copied and renamed during build to .exe.config, so only executables can have and use "App.Config" files using ConfigurationManager directly.
Usually,a VSIX project generates a DLL that is loaded in the Visual Studio executable (devenv.exe), so your project, using ConfigurationManager directly, can only read settings from the devenv.exe.config (folder C:\Program Files (x86)\Microsoft Visual Studio 16.0\Common7\IDE).
And when l test it with my only app.config file in a vsix project,the project seems to be unable to get the value of my custom files only from the default devenv.exe.config which contains only two values TestProjectRetargetTo35Allowed and EnableWindowsFormsHighDpiAutoResizing.This means that in any case, it gets values from devenv.exe.config.
Solution
1#. you can just define the new key in the devenv.exe.config file and you can get it directly from the file.
<appSettings>
<add key ="TestProjectRetargetTo35Allowed" value ="true"/>
<add key ="EnableWindowsFormsHighDpiAutoResizing" value ="true"/>
insert new key here
</appSettings>
2#. You can get this app.config by code and get the values of the keys directly from it.
ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
configMap.ExeConfigFilename = #"xxxxxxxx"; // the path of the custom app.config
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
var test = config.AppSettings.Settings["test"].Value;
In addition, I recommend solution2 is better and easier to solve your issue.
Hope it could help you.

Adding Windows Runtime Component (wraps Class library) in Windows 10 Cordova Project via cmd line by defining it custom plugin's xml doesn't work

I created a Windows universal project with cordova cmd line. (create a new project, added platform windows)
Built the project and run it from cmd line. Works fine.
My requirement is to create my own custom plugin and install it via npm cmd line.
My project also need to access native code with Windows Runtime Component.
I opened the above project CordovaApp in Visual Studio 2015.
Then I added a Windows Runtime Component also I added Newtonsoft library (link here why I added Newtonsoft manually). I added a following Service class:
public sealed class Service
{
public IAsyncOperation<string> Open(string param)
{
return OpenHelper(param).AsAsyncOperation();
}
private async Task<string> OpenHelper(string param)
{
try
{
JObject jObj = JObject.Parse(JArray.Parse(param)[0].ToString());
string message = jObj["message"].ToString();
return message;
}
catch (Exception ex)
{
return "fail";
}
}
}
I wanted to add its dll or winmd file when installing my custom plugin via cmd line. So I copied my .winmd file from bin\x86\MyRuntime.winmd and place it inside my custom plugin folder (\src\windows\lib).
My custom plugin.xml is below:
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-test-plugin"
version="0.1.0">
<name>Launcher</name>
<description>PhoneGap Plugin</description>
<license>MIT</license>
<keywords>phonegap,launcher</keywords>
<js-module src="www/launcher.js" name="Launcher">
<clobbers target="window.launcher" />
</js-module>
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/Launcher.js" name="LauncherProxy">
<merges target="" />
</js-module>
<framework src="src/windows/lib/MyRuntime.winmd" custom="true" />
</platform>
</plugin>
I have launcher.js file in my cordova plugin from where native runtime component is called like below:
Launcher.js
cordova.commandProxy.add("LauncherProxy", {
open: function(successCallback, errorCallback, pluginParam) {
var service = MyRuntime.Service();
service.open(JSON.stringify(pluginParam)).then(function(data) {
successCallback(data);
});
}
});
require("cordova/exec/proxy").add("Launcher", module.exports);
In my index.js, I have this method call on device ready event:
launcher.openFile(function (message) {
Windows.UI.Popups.MessageDialog(message).showAsync();
console.log(message);
}, function () {
});
FYI: Also launcher.js inside the **\www** of my custom plugin has following code structure:
cordova.define("cordova-test-plugin.Launcher", function(require, exports, module) {
var objWindowsLauncher = {
openFile: function(successCallback, errorCallback) {
cordova.exec(
successCallback,
errorCallback,
'LauncherProxy',
'open',
[{
"message": "Hello test message"
}]
);
}
}
module.exports = objWindowsLauncher;
});
Till now it works well. It pop up's Hello test message when app is run.
Now I added a new Class library project for SQLite. Installed sqlite-net (include SQLite.cs and SQLiteAsync.cs files from old project), added Newtonsoft.json dll, SQlite for Universal Windows Platform, Visual C++ 2015 Runtime for Universal Windows Platfrom.
Added this SQLite reference (Class library) to my previous Runtime Component project by right clicking on the Reference and selecting SQLite project.
By doing this, now I can do sqlite operation in runtime component. I build this runtime component and hence its new .winmd file is generated inside bin\x86\Debug. I copied this winmd file and place it inside my custom plugin folder like above.
I removed the plugin and re-added the plugin (cmd line installation) just like above. This time also, the project should work same as previous, but doesn't work.
It throws an exception.
System.IO.FileNotFoundException: Could not load file or assembly 'SQLite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at MyRuntime.Service.<OpenHelper>d__1.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder 1.Start[TStateMachine](TStateMachine& stateMachine)
Another case:
Sometimes, I get this exception with the exact above process:
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
INFO
All the project build configuration is under x86.
Newtonsoft version is: 9.0.1, 10.x.x
Cordova Windows 10 project, Runtime Component and Class Library has: 10.0.14393.0 (Target Version) and 10.0.10240.0 (Min Version)
Cordova version: 7.0.1
Cordova Windows version: 5.0.0
Plugin installation and remove cmd:
cordova plugin remove cordova-test-plugin
cordova plugin add ..\plugins\cordova-test-plugin
I have shared the complete project with custom plugin here in onedrive.
P.S. I can add the Runtime component reference manually and make it work but I want to do with cmd line interface, install pluigns, build and generate packages from cmd line interface without interacting with Visual Studio.
Please let me know your views, I remember when I started to work few months back, it used to work. (adding reference from cmd line by defining .winmd file in plugin.xml (<framework src="src/windows/lib/MyRuntime.winmd" custom="true" />)). It used to work fine. But recently I'm facing above problem.
UPDATE 1
I tried as #Elvis Xia suggested. This seems to load the runtime component as expected. I included all these:
<framework src="src/windows/lib/SQLite.dll" custom="true"/>
<framework src="src/windows/lib/MyRuntime.winmd" custom="true" />
<framework src="src/windows/lib/Newtonsoft.Json.dll" custom="true"/>
in my plugin.xml and installed the plugin via cmd line. There is still some bug while creating SQLite database. I faced system.dllnotfoundexception unable to load dll 'sqlite3' error as:
The problem is, SQLite.dll and NewtonJson.dll should also be added as reference in your plugin. So your plugin.xml should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-test-plugin"
version="0.1.0">
<name>Launcher</name>
<description>PhoneGap Plugin</description>
<license>MIT</license>
<keywords>phonegap,launcher</keywords>
<js-module src="www/launcher.js" name="Launcher">
<clobbers target="window.launcher" />
</js-module>
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/Launcher.js" name="LauncherProxy">
<merges target="" />
</js-module>
<!-- <framework src="src/windows/lib/MyRuntime.winmd" custom="true" /> -->
<framework src="src/windows/lib/SQLite.dll" custom="true"/>
<framework src="src/windows/lib/MyRuntime.winmd" custom="true" />
<framework src="src/windows/lib/Newtonsoft.Json.dll" custom="true"/>
</platform>
</plugin>
And copy SQLite.dll and Newtonsoft.Json.dll under bin\x86\debug\ folder to your plugin's src/windows/lib/. Then it will works fine.

publish a website through MSBuild

I am trying to publish an asp.net website through msbuild on command prompt, but I did not get success.
I tried by creating a new web application and execute below command, it works.
C:\Windows\system32>msbuild.exe "C:\VisualStudio 2012\Projects\HelloWorldSample\HelloWorldSample\HelloWorld\HelloWorldSample.csproj" /p:DeployOnBuild=true /p:PublishProfile="HelloDeploy"
But my problem is, in website I don't have .csproj file. That's why I am unable to execute above command for that.
So please any one help me how I can do deploy for a web site.
Thanks.
If your website has no csproj project file it most likely is a directory containing just your website files. You can convert it to a Web Application (thus getting a csproj file) or directly use msdeploy to generate a deployable package and then use msdeploy to deploy it to your website. This is wat actually would happen under the hood when you run msbuild /p:DeployOnBuild
To create a msdeploy deployable website you can use the following snippet
msdeploy.exe
-verb:sync
-source:iisApp="C:\development\mywebsite\the-website-dir"
-dest:package="C:\temp\mywebsite-package.zip"
-declareParamFile:"C:\development\mywebsite\parameters.xml"
You will need to create at a parameter for the site name in the parameters.xml file which will be packaged with the zipped website project
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<!--
This file contains (among others) references to web.config fields (xpath)
which will be 'parameterized' on package before deploy. The actual values will then be filled in based on the given deploy environment.
-->
<parameter name="IIS Web Application Name" tags="IisApp">
<parameterEntry kind="ProviderPath" scope="iisApp" match="" tags="IisApp" />
</parameter>
</parameters>
This will generate a deployable msdeploy package which you can upload to your IIS by using:
msdeploy.exe -source:package=c:\temp\mywebsite-package.zip -dest:auto,computerName=https://mysite.example.com:8172/MsDeploy.axd,userName=USERNAME,password=PASSWORD,authtype=Basic, -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:example-setParameters.xml -allowUntrusted
Together with a setParameter file
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<setParameter name="IIS Web Application Name" value="mysite.example.com" />
</parameters>

MSBUILD script building solution, but not deploying publishing profile

I have created a publishing profile for my web page, and I can successfully publish using the web deploy interface in Visual Studio (right click project, deploy etc). It builds the project on my local PC, and copies the files across to destination IIS server.
But now I am trying to create a MSBuild command, which should do the same, but it is only building the solution, not copying it across to the server.
My MSbuild command looks like this, and I run it from the solution source directory
msbuild "test.co.za.sln" p:DeployOnBuild=true /p:PublishProfile="test.co.za" /p:UserName="domain\test" /p:Password="test"
Is there anything wrong with my build command? As you can see in the screenshot, it is building successfully, but no files are being copied across. Which makes me wonder if the publishing profile is executed at all.
I have tried various combinations of publishprofile paths, full paths, with extensions, without, nothing seems to copy my files accross.
My publishing profile looks like this App_Data\Publishprofile\test.co.za.pubxml
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<SiteUrlToLaunchAfterPublish>http://test.co.za</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<MSDeployServiceURL>test.co.za</MSDeployServiceURL>
<DeployIisAppPath>test.co.za</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<UserName>domain\test</UserName>
<_SavePWD>True</_SavePWD>
</PropertyGroup>
</Project>
EDIT: This is an existing classic ASP website which I added to a solution, it doesn't contain a ".csproj" file, just a "website.publishproj", which doesn't seem to execute
It doesn't look like you are passing in the VisualStudioVersion property. You should include that. The value will either be 11.0, 12.0, or 14.0 based on the version of Visual Studio you are using. You should likely pass in a value for Configuration as well but it's not required. I've blogged about why this is important at http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx.
You can find the docs for asp.net command line publishing at http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment
Looks like my "website.publishingproj" is never being built when I run the msbuild command. Not sure why, #Sayed do you perhaps know?
I had to create a targets file next to my solution called "after.solutionName.sln.targets" and copy the code from this answer : https://stackoverflow.com/a/15138373/1184603
<!--?xml version="1.0" encoding="utf-8"?-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Deploy Website" AfterTargets="Build">
<Message Text="Starting Website deployment" Importance="high">
</Message>
<MSBuild Projects="$(MSBuildProjectDirectory)\MyWebs\website.publishproj"
BuildInParallel="true" />
</Target>
</Project>
It now publishes correctly from my msbuild script.

ASP.NET website is working in IIS but not in browser

I have deployed my asp.net 2.0 website on IIS, and I tested there by browsing website in IIS and it's working fine.
But I am getting the below error while browsing the website
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'xmlns'.
Source Error:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Previously when we used to create a website in IIS, it worked fine. I have checked the website folder in IIS [ By clicking Property > ASP.NET] and the framwework tageted there is 1.1, and it is in read only mode. If the problem is related to this issue than please let me know how to change it.
In the Property > ASP.NET tab you need to select the 2.0 version in the version combo. If not available, it means that .NET 2.0 is not properly installed with IIS.
I had this exact error message on a machine where I installed .NET 2.0 prior to IIS.
You can fix this by opening a .NET 2.0 SDK Command Prompt, and run
aspnet_regiis.exe -ir
This will register .NET 2.0 in IIS, and you will get it available in the version combo.
NOTE:
An alternative to run it in the SDK command prompt, is to open a standard command window and navigate to the .NET Framework 2.0 installed location and run aspnet_regiis.exe -ir from there.
On my installation this is:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50110>
The error message you're getting is that the attribute xmlns of the element configuration is not recognized. Before anything else, have you tried removing the xmlns attribute?
I've just double checked by looking at a web.config file I have to hand and the start of it looks like this:
<?xml version="1.0"?>
<configuration>
<configSections>
i.e. No xmlns attribute on the configuration element

Resources