Why is VSIX attempting to load random files as assemblies? - visual-studio

In short: When building a VSIX project In Visual Studio 2015, the build process is attempting to load random files (such as icons, .config files, .targets file) as if they were .Net assemblies.
I am attempting to build a VSIX project that includes a referenced project template and a embedded wizard assembly. I've done the exact same thing previously with success, following the steps described at How to: Use Wizards with Project Templates.
This time, however, when I attempt to build the VSIX project I get bizarre errors such as the following:
Could not determine the FullName of the Assembly at "C:\Source\VSTS\Toolkits\v7\Web.Site\v7.2\packages\Microsoft.Net.Compilers.1.3.2\tools\csc.exe.config". Could not load file or assembly 'csc.exe.config' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Note, the compiler is trying to load a config file as if it were an assembly. In fact, I first got this error when it was attempting to load the icon file for the VSIX...as if it were an assembly. If I rename or remove the file in the error message and rebuild I just get the same error but with the next random not-an-assembly file that the compiler encounters.
Why is the compiler attempting to load random files as if they were assemblies? How can I make it stop so that I can actually build my VSIX project?
More info:
This error is thrown by the DetokenizeVsizManifestSource build step defined in Microsoft.VsSDK.targets:
<DetokenizeVsixManifestSource
InputFile="#(SourceVsixManifest)"
OutputFile="$(IntermediateVsixManifest)"
ResolvedReferences="#(_VsixManifestResolvedReferences)">
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</DetokenizeVsixManifestSource>

I had the same problem. It seems you can't add add an applciation to a VSIX. You need the project to output a dll and attach that.
If you need to attach an application try to do so as File not as Project.

Related

How do I make MSBuild work with a UWP solution generated from a Unity3D project?

So I'm trying to automate the process for building a packaged app from a Unity project and I've hit a roadblock when trying to use MSBuild to build the final app packages.
In Unity, when you build for UWP, a folder /UWP/ is generated for the project. These contain csharp projects for two .dlls that are required to build the uwp app.
For me, these dlls got generated in a folder for each platform (x86,x64, and ARM), but this is where I hit the roadblock. To build the app packages I use MSBuild(I've also tried with the Developer Command Prompt - same result) with the command.
MSBuild "{Project}.csproj" /p:Configuration=Debug;AppxBundle=Always;AppxBundlePlatforms="x64";OutputPath="AppxPackages"
This throws the error
"C:\Users\{User}\Desktop\Output\{Project}\{Project}.csproj" (default target) (1) ->
(BeforeResolveReferences target) ->
C:\Users\{User}\Desktop\Output\{Project}\{Project}.csproj(319,5): error MSB3030: Could not copy the file "{path-to-unity-project}\UWP\Assembly-CSharp\bin\AnyCPU\Debug\Unprocessed\Assembly-CSharp.dll" because it was not found.
What is happening here is that MSBuild is attempting to find a dll in a folder "AnyCPU" that simply does not exist.
Is there any way I could tell MSBuild to individually build each platform rather than look for a combined dll, or am I using MSBuild incorrectly?
Even though I was unable to figure out why the Debug configuration looks for an assembly in the wrong directory, thanks to #Leo-MSFT I was able to fix the error that was occurring.
Firstly, I was calling MSBuild on the game project, this needed to be the generated solution instead.
Secondly, instead of using the Debug configuration, I used the Release configuration.
And finally, I was confused by the contents generated by the build compared to a build from Visual Studio (Right Click->Store->Create App Packages...). While VS generates an .appxbundle, using MSBuild will generate individually for each of the platforms selected such as game_x64.appx, game_ARM.appx, and a few more.
You can create the bundle yourself by using the makeappx tool.

Visual Studio 2012 - How to assign multiple build actions to a TypeScript file

I am using Visual Studio 2012 to create a class library project that will also include a number of TypeScript (.ts) files, as well as their generated .js and .js.map files. All of these files need to be included in the assembly as embedded resources, so that they can be exposed to a consuming ASP.NET MVC application via a custom VirtualPathProvider.
Note: although only the generated JavaScript files are essential for the production environment, the .ts and .js.map files must also be accessible to the web application, for debugging.
This presents a conflict, since TypeScript files are usually assigned the TypeScriptCompile build action but I also need them to be assigned EmbeddedResource.
Is there any way to assign multiple build actions to a VisualStudio project component? Alternatively, is there another way to get TypeScript to compile files that are not explicitly marked as TypeScriptCompile or to get Visual Studio to embed files that are not marked as EmbeddedResource?
Thanks for your suggestions,
Tim
If you had a TypeScript file that referenced all of the others, only it would need to have the TypeScriptCompile type as the compiler should walk all the dependencies and compile all the rest too.
So creating a file that acts as the compilation target and that references all of your other files might allow you to change all the rest to EmbeddedResource.

The same wixproj file only works in VS 2012 IDE, but not in VS command prompt

I am trying the steps on this page. I have installed the wix binaries in a folder on my local machine.
So I got a wix installer project created by wix VS 2010 plugin. I can use the VS 2010 IDE to build it and generate the msi file, but I cannot do the same thing with Msbuild in the VS command prompt. When Msbuild try to compile, there is an error complaining the candle.exe cannot be found:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\MyFolder\Wix\candle.exe' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
I am pretty sure the exe is at the right place because VS IDE can find it. I would like to know what am I missing for Msbuild?
Thank you!
I found answer from here: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Error-in-candle-during-build-td7385947.html.
Before unzip the binaries, right click on the zip file, select property and choose Unblock from the first tab. Then you unzip it as normal.
As per the page provided by you, the path entered in the lines of code will help the MSBuild script to identify the WIX binaries.
<PropertyGroup>
<WixToolPath>$(SourceCodeControlRoot)\wix\3.6.3220.0\</WixToolPath>
<WixTargetsPath>$(WixToolPath)Wix.targets</WixTargetsPath>
<WixTasksPath>$(WixToolPath)wixtasks.dll</WixTasksPath>
</PropertyGroup>
The important quote here goes like:
WixTargetsPath property value must be relative to the .wixproj project
file that uses it. The WixTasksPath property is used inside
wix.targets to load WixTasks.dll
The paths should be specified properly according to the folders where you unzipped your files. Otherwise there is a chance for this error to happen. Then also the project will be running fine from VS2010 since that is reffering the WIX binaries from the installed location of WIX. But, MSBuild will refer the values you provide in the above lines of code.
So, can you please provide values you are giving for WixToolPath, WixTargetsPath and WixTasksPath. As well the path to where you are unzipping the wix36-binaries.zip or wix37-binaries.zip.
These information may help in solving this issue and accordingly I will correct this answer as well.

Unable To Reference Wizard Assembly in VSIX Deployed Template

I am trying to create a VISX extension for Visual Studio 2010 that contains a few project templates. These templates aren't very complex, but I want to expose some additional configuration for them during creation via a wizard. I have successfully set up my VISX package to deploy the templates to the directory structure I want in VS2010, but as soon as I try to configure and run a wizard, I receive an error when I create the template along the lines of:
Error: this template attempted to load component assembly
'My.Assembly, Version 1.0.0.0, Culture=neutral, PublicKeyToken=...
My current configuration is as follows:
All the projects live in the same solution.
The VISX project includes project references to the project containing the wizards and to each template.
Each template is built from a project template template (...confusing terminology).
They are added through the .vsixmanifest designer as content, referencing the projects.
Each .vstemplate file has a WizardExtension element pointing to the IWizard implementation and containing assembly.
The wizard assembly is signed.
The .vstemplate files point to their wizards like this:
<WizardExtension>
<Assembly>My.Assembly, Version=1.0.0.1, Culture=neutral, PublicKeyToken=a494da9e6e53f845, Custom=null
</Assembly>
<FullClassName>My.Assembly.Wizard</FullClassName>
</WizardExtension>
This, as far as I can tell, is how I'm supposed to do it. What exactly is going wrong? It looks like it can't find the assembly. Are there any other steps I need to take in order to get the assembly visible to the templates? The assembly is deployed to the extension folder when it is installed (I verified this), so it is at least making it out. Is there something special I need to do to the .vstemplate files to tell them to look in the extensions folder vs the GAC? Did I just miss something?
Note that I have found several pages on the internet stating that I have to GAC the assembly manually or with a script. However, few had my exact scenario (Project template templates being referenced by a VISX project, most examples are using a regular project exported via the project template wizard and having their packages dumped into the VISX folder structure). The only one I found that matched my scenario was an example from Microsoft. I tried to match that, but alas it still does not work. I tried relocating the project I downloaded to reference in this question but I cannot find it again, though.
Using scripts is how we've done this before, but I want to try and make things a little cleaner using VISX packages. I would like to avoid this, but if it's mandatory to script the VISX to install the template to GAC, I can do that.
When deploy the wizard based project template by VSIX Extension, it is better to use Short-Named assembly in .vstemplate. This can avoid the GAC deployment.
In your case, it should be:
<WizardExtension>
<Assembly>My.Assembly</Assembly>
<FullClassName>My.Assembly.Wizard</FullClassName>
</WizardExtension>
I am using VS2015 and faced this issue on and off. When I started building VSIX project with Wizard implementation, everything worked fine for sometime (4-6 weeks) and suddenly it stopped working. After a couple of weeks it would start working again and stop working without notice. Took me long time to find a workaround (still don't know why it suddenly stops).
This is how my VSIX project is built
I have VSIX project, project template and Wizard implementation in
the same solution.
VSIX and Wizard implementation are in the same project.
Added VSIX project dll and project template as Assets in VSIX project source.extension.vsixmanifest.
Project template *.vstemplate has Wizard section which refers to VSIX project with strong name:
<<<<<<<<<<<<<<<<<<<<<<
<WizardExtension>
<Assembly>Test.Template.TemplateInstallerWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ab381f68dc4f5e</Assembly>
<FullClassName>Test.Template.TemplateInstallerWizard.WizardImplementation</FullClassName>
</WizardExtension>
None of these worked for me
Uninstalled extension from VS regular instance via Tools->Extensions
and Updates..
Uninstalled extension from VS experimental instance by
launching VS exp instance from VS2015 command prompt as Administrator:
devenv.exe /rootsuffix exp
and then uninstalling the extension via Tools->Extensions and Updates..
Using short named assembly as explained by #Ethan Wu.
Installing templates via this command from VS2015 command prompt launched as administrator:
devenv /installvstemplates
Rebooting VS2015, my machine several times during this process.
This is what worked for me (thanks to #Ethan Wu)
Remove certificate from VSIX project.
Remove strong name from Project Template *.vstemplate
file
<WizardExtension>
<Assembly>Test.Template.TemplateInstallerWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
<FullClassName>Test.Template.TemplateInstallerWizard.WizardImplementation
Clean and build the project.
Remove extension from VS regular instance and close VS2015 (not
absolutely required)
Install the extension.
Open new VS2015 instance and try to create the project with
wizard.
Couple of things to help debug
When VSIX project is build, in bin\debug folder a file is
created -extension.vsixmanifest which has the assets type.
Look for Asset Type="Microsoft.VisualStudio.Assembly":
AssemblyName value is what is expected in project template's
*.vstemplate WizardExtension section - they should match exactly.
After installing extension, go to VS2015 extension location on
local box:
%appdata%\..\Local\Microsoft\VisualStudio\14.0\Extensions\<some_temp_folder>
open extension.vsixmanifest to ensure that Asset
Type="Microsoft.VisualStudio.Assembly" AssemblyName value is
correctly populated. If required, you can change this value and
restart VS2015 to make this in effect.
Hope this will help someone and save tons of time as there is very little help on Wizard and custom project templates.
Thanks,
RDV
I run into the same problem, but mine came to light when I updated the AssemblyVersion of my wizard project. I checked and the versions in the manifest files matched as they should.
I simply went into C:\Users\Albert\AppData\Local\Microsoft\VisualStudio\16.0_c340331cExp\Extensions, found my extension and deleted it there. Now it works again.
(Note that I did find a few others since I've since changed the company name etc, in the AssemblyInfo file, so it could be the old ones laying around that also caused this)

Deploy dll with resource files to sharepoint 2010 in visual studio 2010

I have problem to add a assembly to my sharepoint project. I have a assembly that contains resource files for different language. I have one file for English, Utility.resx och one for Swedish Utility.sv-SE.resx. When I build it, it will be one dll for the project and one for the swedish language. The problem is when I should deploy it to Sharepoint with Visual Studio. I have added the assembly for the project to my packagefile in my sharepoint project. But when I trying to deploy it but I got the message:
Error occurred in deployment step 'Add Solution': Error: Cannot add the specified assembly to the global assembly cache: Utility.resources.dll
I have tried to specified both sv-SE\Utility.resources.dll and Utility.resources.dll as Location when I added the assembly i package. Note that I want to add it as assembly from project output.
Anyone having an ideas how to solve this problem?
This should help - http://blogs.visigo.com/chriscoulson/deploying-localized-satellite-assemblies-with-sharepoint-2010/
You have to add the resource assemblies using "Add Existing Assembly" and hard code the path to the BIN\release\ folder and NOT "Add Assembly from Project Output" for some reason...
And no - you can't use bin\$(ConfigurationName) -- GAHH!
Why not deploying the resource files as resx?
They need to be added to the manifest.xml as "RootFiles":
<RootFile>
<RootFile Location="Resources\Utility.sv-SE.resx"></RootFile>
<RootFile Location="Resources\Utility.resx"></RootFile>
</RootFiles>
Hope that helps,
marco

Resources