I have a folder of images I want to embed as resources into a WPF app built using Visual Studio 2015. How can I do this dynamically at build time so that the folder contents is copied as-is and the app can access the images using Uri("pack://application:,,,/Resources/" + path)?
To be precise, I do not want to add the images from the folder one by one to the project as the contents of the folder is not constant.
Ideally the folder itself would be embedded as a resource so that the URIs would be Uri("pack://application:,,,/Resources/" + "MyFolder/" + path).
I eventually figured it out based on this other question: the solution is to manually edit the .csproj file using Notepad or equivalent and insert another group like this:
<ItemGroup>
<Resource Include="..\..\_App_\Resources\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
Then whenever you re-open the Visual Studio solution, it will show all files in that folder under the project in the explorer and copy them to the app as resources.
Unfortunately, it doesn't appear possible to put these files under their own folder in the app resources.
Related
I have a working visual studio 2019 project with a simple nuget package, where if I right click 'ClassLibrary2' and click 'pack' it packages my project into a NuGet package
I want to package this folder NxTestware, when I include the folder in my project and try to pack again, it results in errors that come from inside the source folder, like it is trying to build the contents of that folder
Is there some way in visual studio I can tell it that when I click 'pack', do not build the contents of the NxTestware folder?
After trying I can't reproduce your issue on my side, please check your project's csproj file, and refer to this document: How to: Exclude files from the build.
I was creating .exe file via install sheild for my wpf application but at a point where we need to put the project output files I got confused.I want to add xml files considering the fact that it should point to local reference application bin/ debug folder.
How to achieve this? Any help would be appreciated.A walkthrough would be of great use.
I have a silverlight application. When i build the application using VS 2013, it creates ClientBin folder under web project and copies all XAP files into clientbin folder as expected.
However our build process use MSBuild to build all the applications. We have custom .proj file which has bunch of tasks to build the applications. When i execute .proj file using Msbuild command it doesn't not create ClientBin folder
After checking around for problems similar to yours and looking at some of my silverlight projects I would suggest the following:
As you stated you are using a custom .proj file, you should check the custom .prog file and make sure this exists in a <PropertyGroup/>
<SilverlightApplicationList>{GUID}|..\Silverlight_Project_Folder\Silverlight_Project_Name.csproj|ClientBin|False</SilverlightApplicationList>
This value tells MSBuild to copy the XAP in the ClientBin directory.
Take note of the silverlight projects GUID. It can be obtained from the Silverlight app .csproj file:
<ProjectGuid>{00000000-0000-0000-0000-000000000000}</ProjectGuid>
There was also a mention of including the CopySilverlightApplications; task on the build server's Microsoft.WebApplications.targets
Hope this helps
References:
New Silverlight app doesn't generate XAP
How to get the Silverlight XAP copied to the clientbin on build
Silverlight xap file not being copied to ClientBin on Build Server
MSBuild SilverlightApplicationList
I have the SL Control toolkit installed on my machine and I have added a reference to the toolkit DLL (System.Windows.Controls.Toolkit.dll)
I like to have all my external dependencies in a lib folder under the SL project, so I copied over the DLL from the installation dir of the control toolkit to the lib folder, but if I try to add reference to the DLL from this location, VS is still picking up the reference from the installation dir.
What gives?
I ran across this problem everyday. The easy (it feels that way after some time) solution is to unload the project (right click>Unload Project) then right click again en select Edit. Find a reference that is point to another assembly in your lib folder, copy that Xml element and change the 'Hint' path to your assembly.
It will look something like:
<ItemGroup>
<Reference Include="Ninject">
<HintPath>..\..\Ninject.dll</HintPath>
</Reference>
<Reference Include="System" />
<!-- other references removed for breviti-->
</ItemGroup>
The installed DLLs are always searched first, even if you add the DLL by browsing. The path in the properties window (for your added reference) would have shown the "installed" version instead immediately after adding the reference to your copy.
A build machine would not have the toolkit installed. You could uninstall the toolkit and organise the DLLs yourself if you really need that sort of behaviour.
I have a SharePoint (using VSeWSS 1.3) project that creates a WSP file which installs my custom content types. One of the type also installs a custom version of DispForm.aspx which is hosting a Silverlight control, located in the ~/ClientBin as a XAP file.
Is there a way in the ListDefinition.xml file to instruct VSeWSS to deploy my XAP file into ~/ClientBin as part of the WSP solution? I know how to deploy images to the TEMPLATES\images folder, but not to ~/ClientBin .
Philipp
To get the XAP file into the ClientBin directory you could try this. Let the solution deploy the XPA file to a folder within the TEMPLATE directory (12 Hive). With a FeatureRecevier that triggers on the FeatureInstalled event you could then copy the XAP file from its location in the sub folder of the TEMPLATE directory to the ClientBin folder.
The FeatureUnistalled event can be used to remove the XAP file from the ClientBin folder when the solution is retracted.
WSP can place the Files in following locations
Any Sub Folder inside 12 Hive
GAC
Bin directory of the Web Application.
Considering the above I recommand you to Change the Location where you keep the XAP file. You can think about placing it in the _Layouts. That is how I Did