Import solution without Ribbon changes - dynamics-crm

We are trying to import a solution from an org A to an org B such that the ribbon changes made in the org A is not imported. While adding an entity to a solution in org A, we excluded the metadata and added the entity. While exporting this solution from org A and importing it to org B, the ribbon changes made in the entity in the org A replaces all the ribbon changes made to the same entity in the org B.
Is there a way such that the ribbon changes are not included in the solution?

Unfortunately, Ribbondiff xml of Entity Metadata definition is not a sub-component that can be segmented as a part of solution yet.
In other words, there is no granularity to skip the ribbon changes only using solution between environments. Ribbon always goes.
One workaround is to open the CRM ribbon workbench, copy the xml as a backup from Org B. After moving the entity solution from Org A to Org B, paste the backup xml into Org B to restore/publish.

You cannot exclude the ribbon from an entity when exporting in the solution. What you can do is to exclude the global ribbon definition (Solution -> Client Extensions -> Application Ribbons).
I suggest that you remove your changes to the local ribbon of your entity, and instead make a global ribbon customization that targets only the entity you are interested in. If you then exclude the Application Ribbons from your solution, the change will stay behind in your source environment.
You can edit the global ribbon by adding Application Ribbons to a solution:
You would then find the global <RibbonDiffXml> in customizations.xml (located at the very end of the file). There you add the needed XML using the {!EntityLogicalName} placeholder. Finally you can use a DisplayRule to ensure that only your specific entity has the ribbon button shown:
<DisplayRule Id="My.DisplayRule">
<EntityRule EntityName="myEntity" Context="Form" />
</DisplayRule>

Using the SolutionPackager.exe you can exclude the ribbon.
Export the solution from Dynamics 365
Extract using SolutionPackager.exe
In the extracted files, remove the RibbonDiff.xml file from the entity folder
Edit the Entity.xml and remove the <RibbonDiffXml />
Pack the solution using SolutionPackager.exe
NOTE: You will need to do this every time you export

Related

Adding a custom property to the VS Project Designer

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.

Is it possible to configure a csproj file to allow any project item type?

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

Events are disabled in codenameone

I have problem when I want to access events. I already copied the resource files (nativej2me.res) under src directory but still the events are disabled within my project.
Can anyone help me how to arrange the resources so it enables the vents..?
Thanks
Don't move that resource file. Its not the place for it.
I'm guessing you created a handcoded application where GUI builder events aren't supported. You need to create a GUI builder project when creating a new project.
That's a GUI builder project (notice the visual not manual in the brackets)
Just for the googlers out there:
Have a look in the file codenameone_settings.properties - in there you'll find the property userClassAbs=something/StateMachine.java
Its an absolute path and it was showing the wrong directory. After fixing this I was able to add Events in the Designer again.

.NET Entity Framework 4.0 - prevent overwrite

I have a ASP.NET 4.0 Web Application Project, it work with edmx model file generate by MSSQL 2008 and named StaffModel.edmx
I have my custom logic and apply to StaffModel.Designer.cs ,today i open the edmx ,but not re-generate form database, just have a look, but VS2010 overwrite my *.Designer.cs in accident!
No message or confirm to ask me overwrite or not, so how can i disable that in VS2010?
Generally you cannot. .Designer.cs files are autogenerated and should never be modified because every save to EDMX (even after moving some entity in diagram) or T4 template (if you use it) will trigger recreation.
Either move your changes to your own partial classes for your entities or add them directly to code generator - T4 template.

Best way to deploy and reference an XSLT file

In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer.
In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building.
I have currently, created a folder in the deploy location and placed the XSLT's there but I am concerned about relying on a manual process to update these.
Has anyone encountered a similar issue and if so how did they get around it.
It smacks of changing the MSBuild script to copy the build artifacts to the required location, does anyone have examples of this?
Thaks
If you are using Visual Studio 2005/2008, the easiest way to do this is by including your XSLT files as project resources.
Open the Properties for your project.
Select the Resources tab. You will probably see a link that says "This project does not contain a default resources file. Click here to create one." Go ahead and click on that.
Click the Add Resource drop-down near the top and select Add Existing File.
Browse to your XSLT files and select them.
After you have done this, you can easily access the resources in the following manner:
// To get the contents of the resource as a string:
string xslt = global::MyNamespace.Properties.Resources.MyXsltFile;
// To get a Stream containing the resource:
Stream xsltStream = global::MyNamespace.Properties.Resources.ResourceManager.GetStream("MyXsltFile");
If you are using Visual Studio 2003, your best bet is to include those XSLT files as embedded resources for the DLL. In Visual Studio, select the file(s) in Solution Explorer, open the Properties pane, and change the Build Type to "Embedded Resource". You can then use the GetManifestResourceStream method to get a Stream containing the XSLT(s). The name to pass will be based on the default namespace of your assembly, the folder containing the file, and the name of the file.
For example, say your data layer assembly has a default namespace of My.DataLayer. Within your data layer project you have a folder named Templates which contains a file called Transform.xslt. The code to get your XSLT would look like this:
// There are numerous ways to get a reference to the Assembly ... this way works
// when called from a class that is in your data layer. Have a look also at the
// static methods available on the Assembly class.
System.Reflection.Assembly assembly = (GetType()).Assembly;
System.IO.Stream xsltStream = assembly.GetManifestResourceStream("My.DataLayer.Templates.Transform.xslt");
For more information check out this article on CodeProject.
Obvious question maybe, but still has to be asked, did you include the folder containing the XSLT's in the project itself? Is this a web or forms app?
In VS, it is easy to set the properties of the XSLT files in the project to copy on build, by default they do not.
I may have explained myself poorly.
THe Data layer is a class library that a the presentation layer references.
On building the DataLayer I can get the XSLTs to output to the Bin directory of the DataLayer. However when I build and publish the presentation layer, it correctly grabs the DLL but not the XSLTs

Resources