Visual Studio 2010 SharePoint Replaceable Parameter is not being replaced - wcf

I'm creating a custom WCF service for deployment inside SharePoint 2010 following the instructions on the SharePoint Bits Blog.
As step 3 says, I am building contents of my .SVC file. Note that this is a blank text file with a .SVC extension, and I have manually entered the text into this file.
<%# ServiceHost
Language="C#"
Factory="...(omited for length)..."
Service="Assembly.MyService, $SharePoint.Project.AssemblyFullName$" %>
The $SharePoint.Project.AssemblyFullName$ is a replaceable parameter that visual studio is supposed to replace with the strong name of the assembly built by my project when the solution is packaged.
The problem is that the replaceable parameter isn't getting replaced during the package step. My project also includes a visual web part (the .webpart file of which contains the same replaceable parameter) that is having its replaceable parameter replaced correctly.
how do I get the replaceable parameter in my .SVC file to replace during the package step?

Preferred option is to add a new PropertyGroup to the Project.csproj file manually in Notepad (aaargh), but then at least it works on a fresh checkout / other dev pc as well:
<PropertyGroup>
<TokenReplacementFileExtensions>svc</TokenReplacementFileExtensions>
</PropertyGroup>

Have you added .SVC file extension to this list:
Although tokens can theoretically be
used by any file that belongs to a
SharePoint project item included in
the package, by default, Visual Studio
searches for tokens only in package
files, manifest files, and files that
have the following extensions:
XML
ASCX
ASPX
Webpart
DWP
These extensions are defined by the
element in the
Microsoft.VisualStudio.SharePoint.targets
file, located in the …\\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools
folder.
You can, however, add additional file
extensions to the list. To do this,
add a
element to any PropertyGroup in the
SharePoint project file that is
defined before the of the
SharePoint targets file.

Related

How to customize C# .NET Framework Manifest without Visual Studio

I primarily use JetBrains Rider, which appears to lack the option to add a manifest (though my installation of Visual Studio mysteriously lacks "Application Manifest" under the "Add Item" menu anyhow).
So, I created app.manifest and filled it with the desired XML (in my case, it's a vanilla manifest with the classic <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>)... but it didn't work.
I Changed Build Action to EmbeddedResource... but it still didn't work.
I renamed the file to sandbox.exe.manifest... still nothing!
If I open the exe in a text editor, I see two manifests - mine, and the default.
What step am I missing?
You have to specify manifest file name in the project file. Open corresponding csproj file (Solution Explorer -> select your project -> F4 \ Edit sources) and add the next line to the global properties group :
<ApplicationManifest>app.manifest</ApplicationManifest>
For more information you can read this question:
How can I embed an configuration-specific manifest file in my c# app?

MSBUILD Dynamically Create Config XML Dotfuscator

I am trying to obfuscate bunch of files in a directory and every build there are more and more files being generated. I would like to know if there is a way I can dynamically create the Dotfuscator configuration xml file using a MSBUILD task that will generate the xml file every time there is a new file added to the directory?
This might be a good time to use the Directory input. Rather than representing a single assembly (.exe or .dll), this type of Dotfuscator input captures all the assemblies in a directory. When the contents of the directory change, Dotfuscator's build will automatically pick up any new assemblies.
To make a Dotfuscator config file with a Directory input, open the GUI and add an input as you normally would (directions for Community Edition's GUI and for Professional Edition's standalone GUI), but instead of selecting a file from the Browse... dialog, just navigate to the directory and click "Open" while the "File name" is still listed as "Folder Select". Then, save your configuration.
From now on, whenever you run Dotfuscator (whether from the standalone GUI, the command line, the Visual Studio integration, or the MSBuild task), all assemblies in the directory will be processed as input.
Note: If you look at the config file itself, you might be surprised that it will still list individual assemblies:
<input>
<loadpaths />
<asmlist>
<package refid="19e1b0c5-7221-476f-af4b-bafef68edc95">
<file dir="C:\code\BasicTestApp\BasicTestApp\bin" name="Debug" />
<asmlist>
<inputassembly refid="a6da5d8d-c181-4103-840d-d8cc7c85937a">
<option>honoroas</option>
<option>stripoa</option>
<option>transformxaml</option>
<file dir="" name="BasicTestApp.exe" />
</inputassembly>
<inputassembly refid="df84dad0-fbe8-49ab-b8c8-9fb59e706785">
<option>honoroas</option>
<option>stripoa</option>
<option>library</option>
<option>transformxaml</option>
<file dir="" name="ClassLibrary.dll" />
</inputassembly>
</asmlist>
</package>
</asmlist>
</input>
Despite this layout, Dotfuscator will process all assemblies in the C:\code\BasicTestApp\BasicTestApp\bin\Debug directory when it runs a build based off this config file, not just those two listed.
The assembly elements in the config are just there so that you can still make rules against individual assemblies in the GUI (e.g., to make one assembly be in Library Mode).
The list represents the state of the directory when the GUI last modified the config.
Disclaimer: I work for the Dotfuscator team, and am answering this question as part of my job.
Additional note due to clarification in the comments: the directory package has a feature where you can exclude certain assemblies from obfuscation. These assemblies will be treated as a Package Artifact and just copied from input-to-output without modification. Any obfuscated assemblies that refer to these excluded assemblies will still be processed correctly.
To do this in the GUI, right-click on the assembly within the package, and select "Exclude assembly from package". Or, if you'd prefer to edit the config file, add the following <option> tag as a child of each relevant <inputassembly> tag:
<option>artifact</option>
The latest Dotfuscator version 4.41.1 has the latest flag
true
This will generate the Dotfuscator config file if the file is missing. Also you can add this to the csproj as documented in the latest getting started guide https://www.preemptive.com/dotfuscator/pro/userguide/en/getting_started_protect.html

No Class files being generated from Adding a Reference to Web Service

I'm integrated our website with a 3rd party site and using their web service to authenticate. I'm using Visual Studio 2010 with Visual Basic and I'm able to use the URL they gave me to add a web reference using:
website -> add web reference -> URL -> Go -> add reference
However, after I do this there aren't any class files generated in my file structure to reference?
The files generated are:
.discomap
.disco
.wsdl
.xsd
.wsdl
.xsd
.xsd
I don't know if it is relevant, but the webservice was made using visual studio 2008.
Every tutorial I have read online has said that class files should be generated after the reference is successfully added. Am I just reading things wrong or is something else amuck?
Thanks!
I ended up having to generate the class file from the Visual Studio command line. The same link that I used to Add Web Reference was the link needed for the command line text.
This generated two files, a class file and an output.config file. I had to combine the output.config file with my web.config file and then the webservice was called correctly.

Deploy SL4 application with localized DLL imports

I have a VS2010 SL4 project which uses an external Silverlight DLL. The project is localized with multiple RESX files, and the DLL is, too. I usually include external DLLs in my solutions as follows:
1) create a set of virtual folders in my solution like (say the imported DLL is named Sample.dll):
/Lib/Sample/Debug
/Lib/Sample/Release
2) create the same folders structure in the file system and copy under Debug and Release the respective versions of the DLL, so that now I find the following files:
/Lib/Sample/Debug/Sample.dll
/Lib/Sample/Release/Sample.dll
3) add to all the client projects in the solution a reference to /Lib/Sample/Debug/Sample.dll.
4) open the .csproj file of each project with the added reference, and change the Debug part of the path with $(Configuration), so that the right Debug/Release version is picked during build.
Now the question is: in my SL4 solution I can follow the same procedure for importing the language-neutral DLL. But what about its satellite resources? For instance, the French version of the imported DLL is built under subfolder fr-FR and named Sample.resources.dll. How should I include it correctly? Even If I try to manually add it in the compiled XAP under folder fr, it is ignored and the application falls back to its neutral culture...
I think I found it, here's a recap for whom may be interested:
open the .csproj file and ensure you add all your desired languages (separated by semicolons) in . For instance, if you support fr-Fr add <SupportedCultures>fr-Fr</SupportedCultures>.
(had to do this manually, I supposed 1. should be enough): once compiled, open your xap (rename it to .zip and open) and add if not present an element like <AssemblyPart Source="fr-FR/Sample.resources.dll" /> for each imported satellite with resources.
Thanks anyway!

Include an XML file in the Project Build

I have written a small VB.NET simulation program that uses an XML file to configure the simulation. I want to include this file in the project build so that when the application is installed, there will be a default XML file in the required directory.
When I do the Project Publish (within VB 2010 Express), there is no option for including any extra data files in the process.
Is it possible to do this with VB 2010 Express ... or should I try some other project builder/installer.
Any pointers will be very much appreciated,
Regards,
Oliver
The option isn’t found in the publisher, it’s a property of the file itself: when you add a file to the project you can set its file properties in the property window (usually at the right-hand side of the screen, below the file browser).
There you can set its “Build Action” to “Content” and its “Copy to Output Directory” mode to “Copy if newer”.