I have a solution with many projects in it. I have added a new one, but it doesn't seem to share the same build configurations as the others. I want to copy the build configuration from another project and make it available to the new project.
As you can see in the image below, all my other projects have net462-source, but not the one for which I have lowered the drop down. It only has Debug and Release.
How do I copy the build configuration over?
I was unable to find an answer to your copy question but for future projects you can utilize Project Templates and Property Sheets to apply shared configuration across multiple projects.
Use custom Project Template for new projects:
Create a new empty project.
Apply the net462-source configuration to the new project.
Export a new project template by following https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates.
When creating a new project select the new project template and it will automatically apply the correct configuration settings.
Add Custom Project Template
Use shared Property Sheets for multiple projects:
Create a property sheet in the solution folder by following https://learn.microsoft.com/en-us/cpp/build/create-reusable-property-configurations#to-create-a-property-sheet.
Apply your shared properties settings to the .props file either manually or through the Property Manager window and click save.
In the Property Manager select all the projects that you want to apply the property sheet to and right click->Add Existing Property Sheet...
Add Existing Property Sheet
Note: Property sheets can also contain "Conditions" like .vcxproj files.
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='net462-source|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
Related
I'm using VS19 setup project and I would like to hide an additional file that is needed for runtime but I don't like users to see it.
the file is added to the project as an embedded resource
is there any way to hide the file?
I want to display the photos in the folder "Images" directly on a
Image object (In AdProject). But this folder is in another project in my solution(In AdWebApi).
Does anyone know how I can do this?
In the Microsoft documentation, it says that it can be done this way:
MyImage.Source = ImageSource.FromResource("AdWebApi.Images.filename.png", typeof(...)?.GetType().Assembly);
Images Location
But as you can see, the image folder in another project is in the same solution. How can I display images from it?
How can I get the project's (AdWebApi) Assembly ?
It may not be a logical question, but it's for my information only
From this article Images embedded in other projects, I create two project in one solution, one is imageapp, another is mediasample.
I add one image in imageapp.Images folder, set to Build Action: EmbeddedResource. then building this project.
Finally, right-click another project mediasample Dependencies, choose Add Project Reference.... , choose imageapp dll.
now you can get image from other project.
image1.Source = ImageSource.FromResource("imageapp.Images.waterfront.jpg", typeof(imageapp.MainPage).GetTypeInfo().Assembly);
If you add WebAPi in project, right-click another project mediasample Dependencies, choose Add Project Reference.... , click Browse, add System.Web dll by
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1
I am creating a Visual Studio extension and have added a custom configuration-specific property to an existing Microsoft Visual C++ (vcxproj) project using the IVsBuildPropertyStorage interface.
I would like to have that custom property show up in the Project Designer's property pages, as part of a new property page. There is some information on how to achieve that for a custom project type but the approach relies on reimplementing the project system which is not appropriate for all situations. Is there a way to extend the Project Designer for an existing project type?
One way to customise the Project Designer pages for a vcxproj is to include an additional property schema by adding the following:
<ImportGroup Label="PropertySheets" />
<ItemGroup>
<PropertyPageSchema Include="proppage.xml">
<Context>Project</Context>
</PropertyPageSchema>
</ItemGroup>
to a project which can be done by either copying this snippet into the project file directly or by putting it into a custom props file and including that into the project. Details on the structure of a property page schema are available here.
The main issue with this approach is that it requires manual intervention or an explicit step for setting up a project to use the custom property page, making it unsuitable for my use case.
It is also bit cumbersome as it requires shipping one-two additional files with the extension and it leaves a footprint in the project file. I would like to come across a more minimalistic solution that automatically applies to all MS VC++ projects but does not modify the project files unless the user inputs a property into the custom property page.
I'm working on a unique project in that I would like to be able to have CSHTML Razor Views, Windows Forms, and various other "non project type crossing" project item templates in one single project in visual studio.
Is there a way I can override the project type so that it compiles as a Windows Form's project but still allows me to add CSHTML files and other template types to it?
When you edit the .csproj using notepad or an xml editor you'll find that <ProjectTypeGuids> element.
You can then edit it to have an entry like below
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Note: these are Guids from a portable class library project. You need to find correct ProjectTypeGuids for your requirements and add it.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d9d05cdc-96a1-4044-95d8-a4f8885a660a/what-is-the-significance-of-projecttypeguids-tag-in-the-visual-studio-project-file?forum=vsx
I have a solution that contains several projects, lets call them ProjectA and ProjectB. I need ProjectA to have a reference to ProjectB, however when I "Export Template" I can't seem to keep the reference. What I am trying to do is to have it create the reference for me when I create a new project and then automatically name it to what I entered.
This is slightly out of scope for pure Visual Studio templates.
Visual Studio templates supports replacements parameters for templates, so what you could do is:
Inside your ProjectA.zip template file you will find ProjectA.csproj, which is the template for the project
In ProjectA.csproj you will find an <ItemGroup> containing <Reference> entries
Among them should be an entry like <Reference Include="ProjectB">
When you create a project from your ProjectB-template, it's name will be user-specified, so you want to replace ProjectB with a replacement parameter like $Foo$.
This is where it gets out of scope for pure templates: How do you tell visual studio to replace $Foo$? And what would the replacement be?
Your only choice here it to use a custom wizard, which either looks for the ProjectB-type project or asks the user for it.
Here's an outline for how to get the template and custom wizard to get along:
Create a VSIX package project.
Be sure to add the [ProvideBindingPath] attribute to your package. This is required to get the custom wizard registered (otherwise you would need to install it to the GAC, so VS can find it)
Create your wizard, it should implement Microsoft.VisualStudio.TemplateWizard.IWizard
Add your template to the solution and add it as a ProjectTemplate asset in your package's vsixmanifest
In the .vstemplate file of your template, add the following snippet below the <TemplateContent> block:
<WizardExtension>
<Assembly>Your.Packages.Assembly</Assembly>
<FullClassName>Your.Wizard</FullClassName>
</WizardExtension>
That will bring up your wizard when the project is created. You could, in the RunStarted method bring up a dialog which asks for the reference or you could use the automationObject parameter (which actually is a EnvDTE.DTE instance) to try and find the ProjectB project and supply it's name in the replacementsDictionary.