vs2015 keeps removing hintpath from csproj - unit-testing

In order to get my unit test project to build in Jenkins, I had to add a reference to:
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</HintPath>
</Reference>
<Reference Include="System" />
However, vs2015.2 locally keeps removing the hint path. In fact, if I undo it, it immediately comes back. How can I prevent v2015.2 from removing the hint path from the CSPROJ? Or, is there a workaround / better way?

Related

VS2017: How can I write per-file options in .vcxproj, without breaking the filters I've set up?

I learnt how to edit my .vcxproj file to compile some files with /Za and some without.
However it appears that since I'm adding elements to the .vcxproj file, the filters I have set up in the IDE are getting messed up, while the .vcxproj.filters file is turning into a much bigger mess of triple, quadruple, unworking duplicates that writes further duplicates every time it saves.
How can I set a compiler option (like /Za) to automatically apply to all new files, but not some old files, and still have filters working properly?
Here is a condensed example of what I added to my .vcxproj file:
<ItemGroup>
<CLCompile Include="**\*.cpp;" Exclude="BufferTrio.cpp;GraphicsFacade.cpp;">
<AdditionalOptions>/Za %(AdditionalOptions)</AdditionalOptions>
</CLCompile>
<CLCompile Include="BufferTrio.cpp;GraphicsFacade.cpp;">
<AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
</CLCompile>
</ItemGroup>
<ItemGroup>
<None Include="fragmentShader.glsl" />
<None Include="vertexShader.glsl" />
</ItemGroup>
<ItemGroup>
<Text Include="Notes.txt" />
<Text Include="Todo.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="BufferTrio.h" />
<ClInclude Include="Exceptions.h" />
<ClInclude Include="FileUtils.h" />
<ClInclude Include="GraphicsFacade.h" />
</ItemGroup>
This, oddly, puts all .h files in the right filters, but all cpp/c files at the project's root, outside all filters.
Nothing I do in the IDE or with the .vcxproj.filters file makes a difference that isn't just overwritten next time the project saves.
There are two problems which may be a cause of this behavior.
Firstly I would avoid using following pattern when you need a fine grained control over project build:
<CLCompile Include="**\*.cpp;" Exclude="BufferTrio.cpp;GraphicsFacade.cpp;">
<AdditionalOptions>/Za %(AdditionalOptions)</AdditionalOptions>
</CLCompile>
<CLCompile Include="BufferTrio.cpp;GraphicsFacade.cpp;">
<AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
</CLCompile>
It is much easier to control project when all files are included each one individually without the use of globbing **\*.cpp arguments. I doubt that using attribute Exclude="BufferTrio.cpp;GraphicsFacade.cpp;" jointly with Include="**\*.cpp;" on MSBuild property is correctly parsed and used.
Secondly it is best to create two <ItemGroup></ItemGroup> nodes to control independently new and old files and apply to them different compiler flags.
Thirdly you can create explicit <project-name>.vcxproj.filters project file in which filtering can be defined for both sources and headers with one file granularity i.e.:
<?xml version="1.0" encoding="UTF-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="E:\src\ms\dotnet\coreclr-4c\src\jit\alloc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\src\ms\dotnet\coreclr-4c\src\jit\assertionprop.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\src\ms\dotnet\coreclr-4c\src\jit\bitset.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{3E79A5A2-A53A-3F44-8869-13CB1954DF36}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
Finally, it is possible to create build task which would divide files based on the date they were created or committed to repo and which would apply to them compiler flag based on the result of comparison i.e.
<CLCompile Include="BufferTrio.cpp;">
<AdditionalOptions Condition="$(BufferTrioCppCreatedDate) >= $(NumericDateTimeFlagThreshold)">%(AdditionalOptions)</AdditionalOptions>
</CLCompile>

How to use the Web Publishing Pipeline and Web Deploy (MSDEPLOY) to Publish a Console Application?

I would like to use web deploy to publish a Visual Studio "Console" application to a folder on the target system.
I have had some luck, and have been able to produce something similar to what I need, but not quite.
I've added the following to the console .csproj:
added the following projectName.wpp.targets file
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
and I've added the following projectName.wpp.targets:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<DeployAsIisApp>false</DeployAsIisApp>
<IncludeSetAclProviderOnDestination>false</IncludeSetAclProviderOnDestination>
</PropertyGroup>
<ItemGroup>
<FilesForPackagingFromProject Include="$(IntermediateOutputPath)$(TargetFileName).config">
<DestinationRelativePath>bin\%(RecursiveDir)%(FileName)%(Extension)</DestinationRelativePath>
<FromTarget>projectName.wpp.targets</FromTarget>
</FilesForPackagingFromProject>
</ItemGroup>
</Project>
I then edit the .SetParameters.xml file as follows:
<parameters>
<setParameter name="IIS Web Application Name" value="c:\company\project" />
</parameters>
When I then deploy using the generated .cmd file, I get all the files deployed to C:\company\project\bin.
That's not bad, but I'd like to do better. In particular, I'd like to omit the "bin" folder and put all files in the "C:\company\project" folder, and I'd like to be able to specify the ACLs
Has anybody been able to work around these problems?
Ok, so here's the way how to omit the 'bin' folder.
First of all, I'd like to emphasize that all this msdeploy-related stuff is for web apps deployment, and 'bin' folder seems for me to be almost hardcoded deeply inside. So if you want to get rid of it - you have to do some dirty things. Which I did.
We'll have to change $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets project a little bit, so it's better to change not it, but it's copy.
Steps:
1.Backup $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(alternatively, you could install MSBuild.Microsoft.VisualStudio.Web.targets package, redirect your csproj file to Microsoft.WebApplication.targets file obtained from package and work with it).
2. In the $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplicaton.targets find the xml node which looks like <CopyPipelineFiles PipelineItems="#(FilesForPackagingFromProject)"(there are several ones of them, take the one from the line ~2570).
3. Comment the node out, replace with the custom one, so eventually it will look like:
<!--
<CopyPipelineFiles PipelineItems="#(FilesForPackagingFromProject)"
SourceDirectory="$(WebPublishPipelineProjectDirectory)"
TargetDirectory="$(WPPAllFilesInSingleFolder)"
SkipMetadataExcludeTrueItems="True"
UpdateItemSpec="True"
DeleteItemsMarkAsExcludeTrue ="True"
Condition="'#(FilesForPackagingFromProject)' != ''">
<Output TaskParameter="ResultPipelineItems" ItemName="_FilesForPackagingFromProjectTempory"/>
</CopyPipelineFiles>-->
<!-- Copying files to package folder in 'custom'(dirty) way -->
<CreateItem Include="$(OutputPath)\**\*.*">
<Output TaskParameter="Include" ItemName="YourFilesToCopy" />
</CreateItem>
<Copy SourceFiles="#(YourFilesToCopy)"
DestinationFiles="#(YourFilesToCopy->'$(WPPAllFilesInSingleFolder)\%(RecursiveDir)%(Filename)%(Extension)')" />
Then
4. Your projectName.wpp.targets don't have to have FilesForPackagingFromProject, so it will look like:
<!-- targets -->
<PropertyGroup>
<DeployAsIisApp>false</DeployAsIisApp>
<IncludeSetAclProviderOnDestination>false</IncludeSetAclProviderOnDestination>
</PropertyGroup>
<ItemGroup>
<!-- intentionally left blank -->
</ItemGroup>
</Project>
That's it. Worked for me(tm), tested. Let me be honest, I don't like this approach, but that was the only way I made it working in the needed way. It's up to you whether you'll use it in your project or not.
My opinion is not to use msdeploy here - it was not for you task.
Better to write msbuild-scripts from scratch or accept the 'bin' folder, and fight against the framework again once next customization is required.

Running unit tests from a .proj file with MSBuild

I want to run unit tests using MSBuild. Here is how I invoke msbuild today:
msbuild MySolution.sln
Instead, I want to use an MSBuild project file called "MyBuild.proj" like this:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5" DefaultTargets="Build">
<Target Name="Build">
<ItemGroup>
<SolutionToBuild Include="MySolution.sln" />
<TestContainer Include="..\Output\bin\Debug\*unittests.dll"/>
</ItemGroup>
</Target>
</Project>
And then call this command line:
msbuild MyBuild.proj
For some reason, when I do that the command succeeds immediately and the build doesn't even happen. I fear I must be missing something very obvious as I am new to MSBuild.
I suppose I really have 2 questions:
Why doesn't this even build my solution
Is the "TestContainer" element correct for executing my tests
Thanks!
You havent supplied any task to actually do anything,
inside your build target you need a call to an msbuild task, your example becomes:
<Target Name="Build">
<ItemGroup>
<SolutionToBuild Include="MySolution.sln" />
<TestContainer Include="..\Output\bin\Debug\*unittests.dll"/>
</ItemGroup>
<MSBuild Projects="#(SolutionToBuild)"/>
</Target>
this specifies what projects you actually want msbuild to build.
See:http://msdn.microsoft.com/en-us/library/vstudio/z7f65y0d.aspx for more details and the parameters it takes.
Thats part one.
As for part 2? what testing framework are you using? If using mstest id try wrapping the commandline mstest.exe in an msbuild exec statement to get it to run and execute the tests. See an example here:http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/cb87a184-6589-454b-bf1c-2e82771fc3aa

Include AWSSDK refrence to the nant build file

I'm making a build file to build a website written in C#.net using NANT,
but i'm Unable to include the AWSSDK assembly to the file. it give me error
error CS0234: The type or namespace name 'S3' does not exist in the namespace 'Amazon'
the AWSSDK is present in the c:/windows/assembly folder
and this is what i tried
<references>
<include name="/WINDOWS/assembly/AWSSDK.dll" />
</references>
Note :-
<Reference Include="AWSSDK, Version=1.3.19.0, Culture=neutral,
PublicKeyToken=cd2d24cd2bace800, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>/WINDOWS/assembly/</HintPath>
</Reference>
Doesn't work i guess Reference Include=is not the part of the NANT
Make sure you're importing the correct namespace.
<imports>
<import namespace="Amazon.S3" />
</imports>

What's the correct wrong with my project template

I'm trying to write some project and file templates for MonoDevelop (Android, Console and iOS) and can't seem to get the mpack files to install, I keep getting this error when installing the mpack file the monodevelop addin manager:
The add-in MonoDevelop.MonoAndroid.2.8.1.2 is trying to extend /MonoDevelop/Ide/About, but there isn't any add-in defining this extension point.
And here is my template, if you see anything silly, please let me know.
Thanks,
Kenny.
<Runtime>
<Import file="__PreviewImage.png"/>
<Import file="__TemplateIcon.png"/>
</Runtime>
<Dependencies>
<Addin id="::MonoDevelop.Ide" version="2.8"/>
</Dependencies>
<Extension path="/MonoDevelop/Ide/ProjectTemplates">
<ProjectTemplate id="iFactrCrossPlatformAndroid" file="iFactrCrossPlatformAndroid.xpt.xml" />
<ProjectTemplate id="iFactrCrossPlatformTouch" file="iFactrCrossPlatformTouch.xpt.xml" />
<ProjectTemplate id="iFactrAndroid" file="iFactrAndroid.xpt.xml" />
</Extension>
I'm assuming you have the correct attributes on your root element. If so, the error would seem to indicate that you have an old copy of MonoDevelop.MonoAndroid.dll somewhere, and it's confusing the addin engine for some reason.
Note also that you need to import all the addin's files (except the manifest) to get them included in the mpack.
<Runtime>
<Import file="__PreviewImage.png"/>
<Import file="__TemplateIcon.png"/>
<Import file="iFactrCrossPlatformAndroid.xpt.xml"/>
<Import file="iFactrCrossPlatformTouch.xpt.xml"/>
<Import file="iFactrAndroid.xpt.xml"/>
</Runtime>