Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Custom Solution And Project Platforms

$
0
0

Hello all.  I have created a custom VSPackage and Project Type that exposes custom Project Platforms (x86, x64).  My problem appears to be multiple things at once.

1.) When I open the Configuration Manager and try to bind aSolution Platform to a Project Platform, it doesn't persist.  As soon as I change the current Project Platform drop-down, my binding gets erased.

2.) Even though my Project and Solution does not contain the AnyCPU Platform dropdown anywhere, When trying to build the project, the$(Platform) variable in MSBuild has the value "AnyCPU" when it actually should reflect whatever platform is selected in the Solution Platform drop-down (x86, x64).

Here is my code implementing custom Project Platforms:

using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Project;
using Microsoft.VisualStudio.Shell.Interop;
using System.Runtime.InteropServices;

namespace PSE.VisualLinux
{
	[ComVisible(true)]
	class LinuxProjectConfigProvider : ConfigProvider
	{
		enum EConfig
		{
			Debug = 0,
			Release
		}

		enum EPlatform
		{
			x86 = 0,
			x64
		}

		public LinuxProjectConfigProvider(ProjectNode projNode) :
			base(projNode)
		{

		}


		public override int GetCfgProviderProperty(int propid, out object var)
		{
			var = false;
			switch ((__VSCFGPROPID)propid)
			{
				case __VSCFGPROPID.VSCFGPROPID_SupportsCfgAdd:
					var = true;
					break;

				case __VSCFGPROPID.VSCFGPROPID_SupportsCfgDelete:
					var = true;
					break;

				case __VSCFGPROPID.VSCFGPROPID_SupportsCfgRename:
					var = true;
					break;

				case __VSCFGPROPID.VSCFGPROPID_SupportsPlatformAdd:
					var = true;
					break;

				case __VSCFGPROPID.VSCFGPROPID_SupportsPlatformDelete:
					var = true;
					break;
			}
			return VSConstants.S_OK;
		}

		public override int GetPlatformNames(uint celt, string[] names, uint[] actual)
		{
			if (celt == 0)
			{
				celt = 2;
				names = new string[2];
			}

			for (int i = 0; i < celt; i++)
			{
				names[i] = ((EPlatform)i).ToString();
				if (i == 1)
					break;
			}
			if (actual != null)
				actual[0] = celt;
			else
				actual = new uint[1] { celt };
			return Microsoft.VisualStudio.VSConstants.S_OK;
		}

		public override int GetSupportedPlatformNames(uint celt, string[] names, uint[] actual)
		{
			if (celt == 0)
			{
				celt = 2;
				names = new string[2];
			}

			for (int i = 0; i < celt; i++)
			{
				names[i] = ((EPlatform)i).ToString();
				if (i == 1)
					break;
			}
			if (actual != null)
				actual[0] = celt;
			else
				actual = new uint[1] { celt };
			return Microsoft.VisualStudio.VSConstants.S_OK;
		}
	}
}

Here is my custom Project Type Template:

<?xml version="1.0" encoding="utf-8" ?><Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><UsingTask TaskName="PSE.VisualLinux.LinuxTask" AssemblyFile="C:\Users\guita_000\Documents\visual studio 2015\Projects\VisualLinux\VisualLinux\bin\Debug\VisualLinux.dll"></UsingTask><PropertyGroup><ProjectGuid>$guid1$</ProjectGuid></PropertyGroup><PropertyGroup><Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration><Platform Condition=" '$(Platform)' == '' ">x86</Platform></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'"><RemotePort>22</RemotePort><RemoteIP>0.0.0.0</RemoteIP><RemoteUserName>user</RemoteUserName><RemotePassword>pass</RemotePassword></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"><RemotePort>22</RemotePort><RemoteIP>0.0.0.0</RemoteIP><RemoteUserName>user</RemoteUserName><RemotePassword>pass</RemotePassword></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'"><RemotePort>22</RemotePort><RemoteIP>0.0.0.0</RemoteIP><RemoteUserName>user</RemoteUserName><RemotePassword>pass</RemotePassword></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"><RemotePort>22</RemotePort><RemoteIP>0.0.0.0</RemoteIP><RemoteUserName>user</RemoteUserName><RemotePassword>pass</RemotePassword></PropertyGroup><ImportGroup></ImportGroup><Target Name="Build"><LinuxTask Type="Build" Configuration="$(Configuration)" Platform="$(Platform)" /></Target><Target Name="Rebuild"><LinuxTask Type="Rebuild" Configuration="$(Configuration)" Platform="$(Platform)" /></Target><Target Name="Clean"><LinuxTask Type="Clean" Configuration="$(Configuration)" Platform="$(Platform)" /></Target><Target Name="GetFrameworkPaths" /><Target Name="ResolveAssemblyReferences" /></Project>

I really hope someone can help me solve these issues.  Thank you for you time and attention.




Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>