MSBuild giving "invalid version file" on F# - f#

I'm recently unable to build F# with MSBuild. It is giving me an error "invalid version file". The generated compiler options below show --versionfile:version.htm being added, and I'm not sure why.
I did find that if I go to C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.targets, and remove the line VersionFile="$(VersionFile)" it starts working again. However I don't know where that file came from or why that line is there, and I don't want to be working with a non-standard dev box. Can anyone shed light on what's happening here?
Here's a dump of the whole output.
$ "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj"
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 5/4/2017 6:10:21 PM.
Project "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" on node 1 (default targets).
CoreCompile:
C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe -o:obj\Debug\Library1.dll -g --debug:full --noframework --define:DEBUG --define
:TRACE --doc:bin\Debug\Library1.XML --optimize- --tailcalls- --versionfile:version.htm -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FS
harp\.NETFramework\v4.0\4.4.0.0\FSharp.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dl
l" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Core.dll" -r:"C:\Program Files (x86)\Reference Ass
emblies\Microsoft\Framework\.NETFramework\v4.6\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\S
ystem.Numerics.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ "C:\Users\dafohl\A
ppData\Local\Temp\.NETFramework,Version=v4.6.AssemblyAttributes.fs" AssemblyInfo.fs Library1.fs
FSC : warning FS0075: The command-line option 'versionfile' is for test purposes only [C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1 \Library1\Library1.fsproj]
FSC : warning FS2015: The 'AssemblyVersionAttribute' has been ignored because a version was given using a command line option [C:\Users\dafohl\Docume nts\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
FSC : error FS0205: Invalid version file 'C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\version.htm' [C:\Users\dafohl\Docum ents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
Done Building Project "C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" (default target) (1) ->
(CoreCompile target) ->
FSC : warning FS0075: The command-line option 'versionfile' is for test purposes only [C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Librar y1\Library1\Library1.fsproj]
FSC : warning FS2015: The 'AssemblyVersionAttribute' has been ignored because a version was given using a command line option [C:\Users\dafohl\Docu ments\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
"C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj" (default target) (1) ->
(CoreCompile target) ->
FSC : error FS0205: Invalid version file 'C:\Users\dafohl\Documents\Visual Studio 2015\Projects\Library1\Library1\version.htm' [C:\Users\dafohl\Doc uments\Visual Studio 2015\Projects\Library1\Library1\Library1.fsproj]
2 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.68
Here are the original contents of Microsoft.FSharp.targets:
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file defines the steps in the standard build process specific for F# .NET projects.
For example, it contains the step that actually calls the F# compiler. The remainder
of the build process is defined in Microsoft.Common.targets, which is imported by
this file.
Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Fsc" AssemblyFile="FSharp.Build.dll"/>
<UsingTask TaskName="CreateFSharpManifestResourceName" AssemblyFile="FSharp.Build.dll"/>
<PropertyGroup>
<ImportByWildcardBeforeMicrosoftFSharpTargets Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == ''">true</ImportByWildcardBeforeMicrosoftFSharpTargets>
<ImportByWildcardAfterMicrosoftFSharpTargets Condition="'$(ImportByWildcardAfterMicrosoftFSharpTargets)' == ''">true</ImportByWildcardAfterMicrosoftFSharpTargets>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore\*" Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore')"/>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<DefaultLanguageSourceExtension>.fs</DefaultLanguageSourceExtension>
<Language>F#</Language>
<TargetRuntime>Managed</TargetRuntime>
<Tailcalls Condition="'$(Tailcalls)'==''">$(Optimize)</Tailcalls>
<FrameworkRegistryBase Condition="'$(TargetFrameworkIdentifier)'=='Silverlight'">Software\Microsoft\Microsoft SDKs\$(TargetFrameworkIdentifier)</FrameworkRegistryBase>
<!-- Visual studio requires a non-empty RootNamespace value for "Add New Item" to work. -->
<RootNamespace Condition="'$(RootNamespace)'==''">RootNamespace</RootNamespace>
<Actual32Bit Condition="'$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0'">false</Actual32Bit>
<Actual32Bit Condition="!('$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0')">$(Prefer32Bit)</Actual32Bit>
</PropertyGroup>
<!--
The CreateManifestResourceNames target create the manifest resource names from the .RESX
files.
[IN]
#(EmbeddedResource) - The list of EmbeddedResource items that have been pre-processed to add metadata about resource type
Expected Metadata "Type" can either be "Resx" or "Non-Resx"
[OUT]
#(EmbeddedResource) - EmbeddedResource items with metadata
For F# applications the transformation is like:
Resources1.resx => Resources1 => Build into main assembly
SubFolder\Resources1.resx => SubFolder.Resources1 => Build into main assembly
Resources1.fr.resx => Resources1.fr => Build into satellite assembly
Resources1.notaculture.resx => Resources1.notaculture => Build into main assembly
For other project systems, this transformation may be different.
-->
<PropertyGroup>
<CreateManifestResourceNamesDependsOn></CreateManifestResourceNamesDependsOn>
</PropertyGroup>
<Target
Name="CreateManifestResourceNames"
Condition="'#(EmbeddedResource)' != ''"
DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
>
<ItemGroup>
<_Temporary Remove="#(_Temporary)" />
</ItemGroup>
<!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources -->
<CreateFSharpManifestResourceName
ResourceFiles="#(EmbeddedResource)"
RootNamespace="$(RootNamespace)"
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')">
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
</CreateFSharpManifestResourceName>
<!-- Create manifest names for all culture non-resx resources -->
<CreateFSharpManifestResourceName
ResourceFiles="#(EmbeddedResource)"
RootNamespace="$(RootNamespace)"
PrependCultureAsDirectory="false"
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'">
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
</CreateFSharpManifestResourceName>
<ItemGroup>
<EmbeddedResource Remove="#(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' == ''"/>
<EmbeddedResource Include="#(_Temporary)" />
<_Temporary Remove="#(_Temporary)" />
</ItemGroup>
</Target>
<ItemGroup>
<DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/>
</ItemGroup>
<ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true' and '$(PdbFile)' != ''">
<_DebugSymbolsIntermediatePathTemporary Include="$(PdbFile)"/>
<!-- Add any missing .pdb extension, as the compiler does -->
<_DebugSymbolsIntermediatePath Include="#(_DebugSymbolsIntermediatePathTemporary->'%(RootDir)%(Directory)%(Filename).pdb')"/>
</ItemGroup>
<PropertyGroup>
<CoreCompileDependsOn>_ComputeNonExistentFileProperty</CoreCompileDependsOn>
</PropertyGroup>
<Target
Name="CoreCompile"
Inputs="$(MSBuildAllProjects);
#(CompileBefore);
#(Compile);
#(CompileAfter);
#(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
#(ReferencePath);
#(CompiledLicenseFile);
#(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
#(CustomAdditionalCompileInputs);
$(VersionFile);
$(KeyOriginatorFile)"
Outputs="#(DocFileItem);
#(IntermediateAssembly);
#(_DebugSymbolsIntermediatePath);
$(NonExistentFile);
#(CustomAdditionalCompileOutputs)"
Returns=""
DependsOnTargets="$(CoreCompileDependsOn)"
>
<Error
Condition="'$(SilverlightVersion)' != '' and '$(SilverlightVersion)' != 'v5.0'"
Text="In this version of Visual Studio, F# for Silverlight can only target Silverlight v5.0. Use a prior version of Visual Studio to target previous versions of Silverlight with F#."
/>
<Warning
Condition="'$(Win32ResourceFile)' != '' "
Text="The property <Win32ResourceFile> has been renamed to <Win32Resource>. Update your project file to ensure that the correct value is passed via the --win32res option to the F# compiler."
/>
<!-- Condition is to filter out the _CoreCompileResourceInputs so that it doesn't pass in culture resources to the compiler -->
<Fsc Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
BaseAddress="$(BaseAddress)"
CodePage="$(CodePage)"
DebugSymbols="$(DebugSymbols)"
DebugType="$(DebugType)"
DefineConstants="$(DefineConstants)"
DisabledWarnings="$(NoWarn)"
DocumentationFile="$(DocumentationFile)"
GenerateInterfaceFile="$(GenerateInterfaceFile)"
KeyFile="$(KeyOriginatorFile)"
LCID="$(LCID)"
NoFramework="true"
Optimize="$(Optimize)"
OtherFlags="$(OtherFlags)"
OutputAssembly="#(IntermediateAssembly)"
PdbFile="$(PdbFile)"
Platform="$(PlatformTarget)"
Prefer32Bit="$(Actual32Bit)"
References="#(ReferencePath)"
ReferencePath="$(ReferencePath)"
Resources="#(_CoreCompileResourceInputs);#(CompiledLicenseFile);#(AdditionalEmbeddedResource)"
Sources="#(CompileBefore);#(Compile);#(CompileAfter)"
Tailcalls="$(Tailcalls)"
TargetType="$(OutputType)"
ToolExe="$(FscToolExe)"
ToolPath="$(FscToolPath)"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
Utf8Output="$(Utf8Output)"
VersionFile="$(VersionFile)"
VisualStudioStyleErrors="$(VisualStudioStyleErrors)"
WarningLevel="$(WarningLevel)"
WarningsAsErrors="$(WarningsAsErrors)"
Win32ManifestFile="$(Win32Manifest)"
Win32ResourceFile="$(Win32Resource)"
SubsystemVersion="$(SubsystemVersion)"
HighEntropyVA="$(HighEntropyVA)"
TargetProfile="$(TargetProfile)"
SqmSessionGuid="$(SqmSessionGuid)"
/>
<ItemGroup>
<_CoreCompileResourceInputs Remove="#(_CoreCompileResourceInputs)" />
</ItemGroup>
</Target>
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets"/>
<!--
============================================================
GenerateTargetFrameworkMonikerAttribute
Emit the target framework moniker attribute as a code fragment into a temporary source file for the compiler.
============================================================
-->
<Target Name="GenerateTargetFrameworkMonikerAttribute" BeforeTargets="BeforeCompile" DependsOnTargets="PrepareForBuild;GetReferenceAssemblyPaths" Inputs="$(MSBuildThisFileFullPath)" Outputs="$(TargetFrameworkMonikerAssemblyAttributesPath)" Condition="'$(GenerateTargetFrameworkAttribute)' == 'true'">
<PropertyGroup>
<!-- This attribute is only available in mscorlib v4 and later -->
<AdditionalSourcesText Condition="'$(TargetFrameworkMoniker)' != '' and '$(TargetingClr2Framework)' != 'true'">
$(AdditionalSourcesText)
namespace Microsoft.BuildSettings
[<System.Runtime.Versioning.TargetFrameworkAttribute("$(TargetFrameworkMoniker)", FrameworkDisplayName="$(TargetFrameworkMonikerDisplayName)")>]
do ()
</AdditionalSourcesText>
</PropertyGroup>
<!-- This is a file shared between projects so we have to take care to handle simultaneous writes (by ContinueOnError)
and a race between clean from one project and build from another (by not adding to FilesWritten so it doesn't clean) -->
<WriteLinesToFile
File="$(TargetFrameworkMonikerAssemblyAttributesPath)"
Lines="$(AdditionalSourcesText)"
Condition="'$(AdditionalSourcesText)' != ''"
ContinueOnError="true"
Overwrite="true"/>
<ItemGroup>
<CompileBefore Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" Condition="'$(AdditionalSourcesText)' != ''"/>
</ItemGroup>
</Target>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter\*" Condition="'$(ImportByWildcardAfterMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter')"/>
</Project>

Silly me, this was caused by some CoreXT setting in my work environment when launching VS from the command line where CoreXT had been loaded. When starting VS from a fresh command line or from the start menu the problem goes away.
No idea what setting exactly got changed by CoreXT or where, but that was definitely the culprit.

Related

How do I specify a target architecture when building projects in Visual Studio code?

I am new to VS code/F# and I am trying to build a F# console app (on both Windows workstation and on my Linux computer).
I installed the Ionide extension together with FAKE.
The code I am considering is the Iris example (see How to translate the intro ML.Net demo to F#?), creating a New F# Project with Ionide and using Microsoft.ML.
My iris.fsproj is
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<DebugType>portable</DebugType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Compile Include="iris.fs" />
<None Include="App.config" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
When running the script (which I do with the "play" button aka F#: run script provided with VS Code/Ionide) I get:
C:\Users\MyUser\.nuget\packages\microsoft.ml\0.2.0\build\Microsoft.ML.targets(16,5): error : Microsoft.ML currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'.
together with
Running build failed.
Error:
System.Exception: dotnet build failed
How do I target x64 with the project structure provided by Ionide?
It should be as simple as adding the following line to your PropertyGroup section:
<PlatformTarget>x64</PlatformTarget>
There are more complicated setups possible using the Condition attribute to set the platform target based on various command-line arguments to the compiler, but that should be the simplest way to get you up and running.

Build error on Jenkins calling F# compiler with --targetprofile parameter

We are building an Azure solution on Jenkins. This contains several F# projects, a Azure Cloud deployment project, and a C# Azure worker role.
On developer boxes it builds fine. When building on Jenkins we get:
"C:\Program Files (x86)\Jenkins\jobs\REDACTED.sln" (Clean;Build target) (1) ->
"C:\Program Files (x86)\Jenkins\jobs\REDACTED QA\workspace\REDACTED\REDACTED.csproj" (default target) (5:4) ->
"C:\Program Files (x86)\Jenkins\jobs\REDACTED QA\workspace\REDACTED.FSharp.AWS.S3\REDACTED.FSharp.AWS.S3.fsproj" (default target) (6:6) ->
(CoreCompile target) ->
FSC : error FS1052: Invalid value 'Qa' for '--targetprofile', valid values are 'mscorlib' or 'netcore'. [C:\Program Files (x86)\Jenkins\jobs\REDACTED QA\workspace\REDACTED.FSharp.AWS.S3\REDACTED.FSharp.AWS.S3.fsproj]
The problem seems to be something to do with an MSBuild parameter called 'TargetProfile' we need for the Azure aspects to specify which configuration to use (e.g. UAT or QA) and an undocumented F# parameter called --targetprofile which expects the values mscorlib or netcore.
We'd probably like a workaround which decouples these two usages of 'targetprofile'. Ideally we'd like not to have to fiddle with things like F#'s targets file as obviously we'd have to remember to apply this in all the places we might build now and in the future.
Blah, collision between MSBuild property names.
Maybe you can work around by defining a target in your project that runs directly before the F# compile target, and sets the F# TargetProfile to mscorlib, then also define a target that runs directly after F# compile that swaps the value back to whatever it was before.
From a quick test this seems to work ok.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<!-- assume TP has Azure-specific value -->
<TargetProfile>QA</TargetProfile>
</PropertyGroup>
<Target Name="BeforeFSharpCompile" BeforeTargets="CoreCompile">
<PropertyGroup>
<TempTargetProfile>$(TargetProfile)</TempTargetProfile>
<TargetProfile>mscorlib</TargetProfile>
</PropertyGroup>
<Message Text="Swapped from $(TempTargetProfile) to $(TargetProfile)" />
</Target>
<Target Name="AfterFSharpCompile" AfterTargets="CoreCompile">
<PropertyGroup>
<TargetProfile>$(TempTargetProfile)</TargetProfile>
</PropertyGroup>
<Message Text="Swapped back to $(TargetProfile)" />
</Target>
</Project>

TFS: Wix using TfvcTemplate.12 unable to find source files

I need to use TfvcTemplate.12.xaml because of its Pre and Post build script execution support and I need to run a Powershell script as PreBuild event.
On TFS 2013, Building a Wix project using old DefaultTemplate.xaml works fine. While trying to build using new default template TfvcTemplate.12.xaml builds the csharp project fine, but Wix is unable to find its files, while files are present at same location.
Here is Wix code:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define SourceDir=$(var.OutDir)?>
<?warning **************** Target=$(var.TargetDir) ***********?>
<?warning **************** src=$(var.SourceDir) **************?>
<Product Id="*" Language="1033" Manufacturer="Test" Name="Testing" UpgradeCode="DB7DAC5A-ED29-45E6-8029-89F6486A9ACA" Version="1.0.0.0">
<Package Compressed="yes" InstallerVersion="200" Platform="x64" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="ProgFiles">
<Directory Id="bin" Name="bin">
<Component Id="AddProjToSln.exe" Guid="*">
<File Id="AddProjToSln.exe" KeyPath="yes" Source="$(var.SourceDir)AddProjToSln.exe" />
</Component>
<Component Id="AddProjToSln.exe.config" Guid="*">
<File Id="AddProjToSln.exe.config" KeyPath="yes" Source="$(var.SourceDir)AddProjToSln.exe.config" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Level="1" Title="TestFe">
<ComponentGroupRef Id="Testing" />
</Feature>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
</Product>
<Fragment>
<ComponentGroup Id="Testing">
<ComponentRef Id="AddProjToSln.exe" />
<ComponentRef Id="AddProjToSln.exe.config" />
</ComponentGroup>
</Fragment>
</Wix>
Here is the log from TFS:
Build started 10/13/2014 5:24:15 PM.
1>Project "D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln.sln"
on node 1 (default targets).
1>ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
1>Project "D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln.sln"
(1) is building
"D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln\AddProjToSln.csproj"
(2) on node 1 (default targets).
2>PrepareForBuild:
Creating directory "obj\Debug\".
1>Project "D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln.sln"
(1) is building
"D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj"
(3) on node 2 (default targets).
3>PrepareForBuild:
Creating directory "obj\Debug\".
Compile:
C:\Program Files (x86)\WiX Toolset v3.8\bin\candle.exe -dDebug -d"DevEnvDir=Undefined if not building from within Visual Studio"
-dSolutionDir=D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\
-dSolutionExt=.sln -dSolutionFileName=AddProjToSln.sln -dSolutionName=AddProjToSln -dSolutionPath=D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln.sln
-dConfiguration=Debug -dOutDir=D:\Builds\31\47\bin\ -dPlatform=x86 -dProjectDir=D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\
-dProjectExt=.wixproj -dProjectFileName=test_install.wixproj -dProjectName=test_install -dProjectPath=D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj
-dTargetDir=D:\Builds\31\47\bin\ -dTargetExt=.msi -dTargetFileName=test.msi -dTargetName=test -dTargetPath=D:\Builds\31\47\bin\test.msi -out obj\Debug\ -arch x86 Product.wxs
3>D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(4):
warning CNDL1096: **************** Target=D:\Builds\31\47\bin\
*********** [D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
3>D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(5):
warning CNDL1096: **************** src=D:\Builds\31\47\bin\
************** [D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
Link:
C:\Program Files (x86)\WiX Toolset v3.8\bin\Light.exe -out D:\Builds\31\47\bin\test.msi -pdbout D:\Builds\31\47\bin\test.wixpdb
-cultures:null -contentsfile obj\Debug\test_install.wixproj.BindContentsFileListnull.txt
-outputsfile obj\Debug\test_install.wixproj.BindOutputsFileListnull.txt
-builtoutputsfile obj\Debug\test_install.wixproj.BindBuiltOutputsFileListnull.txt
-wixprojectfile D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj
obj\Debug\Product.wixobj
2>GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input
files.
3>D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(12):
error LGHT0103: The system cannot find the file
'D:\Builds\31\47\bin\AddProjToSln.exe'.
[D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
3>D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(15):
error LGHT0103: The system cannot find the file
'D:\Builds\31\47\bin\AddProjToSln.exe.config'.
[D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
3>Done Building Project "D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj"
(default targets) -- FAILED.
2>CoreCompile:
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:AnyCPU
/errorreport:prompt /warn:4 /main:AddProjToSln.Program /highentropyva+
/reference:"c:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\PublicAssemblies\envdte.dll" /reference:"c:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\PublicAssemblies\envdte100.dll" /reference:"c:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\PublicAssemblies\envdte80.dll" /reference:"c:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\PublicAssemblies\envdte90.dll" /reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\Microsoft.CSharp.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\Microsoft.VisualBasic.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Core.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Data.DataSetExtensions.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Data.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Windows.Forms.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Xml.dll"
/reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Xml.Linq.dll"
/debug+ /debug:full /filealign:512 /optimize-
/out:obj\Debug\AddProjToSln.exe /subsystemversion:6.00 /target:exe
/utf8output /win32icon:"Crystal_Clear_mimetype_recycled (2).ico"
Program.cs Properties\AssemblyInfo.cs
"C:\Users\tfsbuild\AppData\Local\Temp.NETFramework,Version=v4.5.AssemblyAttributes.cs"
_CopyAppConfigFile:
Copying file from "App.config" to "D:\Builds\31\47\bin\AddProjToSln.exe.config".
CopyFilesToOutputDirectory:
Copying file from "obj\Debug\AddProjToSln.exe" to "D:\Builds\31\47\bin\AddProjToSln.exe".
AddProjToSln -> D:\Builds\31\47\bin\AddProjToSln.exe
Copying file from "obj\Debug\AddProjToSln.pdb" to "D:\Builds\31\47\bin\AddProjToSln.pdb".
2>Done Building Project "D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln\AddProjToSln.csproj"
(default targets).
1>Done Building Project "D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln.sln"
(default targets) -- FAILED.
Build FAILED.
"D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln.sln"
(default target) (1) ->
"D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj"
(default target) (3) ->
(Compile target) ->
D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(4):
warning CNDL1096: **************** Target=D:\Builds\31\47\bin\
*********** [D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(5):
warning CNDL1096: **************** src=D:\Builds\31\47\bin\
************** [D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
"D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\AddProjToSln.sln"
(default target) (1) ->
"D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj"
(default target) (3) ->
(Link target) ->
D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(12):
error LGHT0103: The system cannot find the file
'D:\Builds\31\47\bin\AddProjToSln.exe'.
[D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\Product.wxs(15):
error LGHT0103: The system cannot find the file
'D:\Builds\31\47\bin\AddProjToSln.exe.config'.
[D:\Builds\31\47\src\MyComp\Playground\MyUser\Utilities\VisualStudio\TestInstall\test_install.wixproj]
2 Warning(s)
2 Error(s)
Time Elapsed 00:00:01.04
I verified multiple times that files are there and it builds without any problem at command line using MsBuild and Wix Tool set as well.
I'm unable to figure out why using TfvcTemplate.12.xaml, wix is unable to see its files while these are present intact there....
Any help would be really appreciated.
So, finally I was able to solve this after a whole day struggle. Like Digg a mountain and got a mice :).
Actually TfvcTemplate.12.xaml seems to be executing MsBuild with parallel processing enabled (/m), while in my VS Solution, Wix project was added independently i.e. in Build Order it was the last project to build, but I never set other projects as its dependencies. So MSBuild found that it has no dependency and ignored its Build Order and simply building it either on random order or as first project. So naturally installer project was unable to find its source files and so failing.
I verified this phenomena by removing /m:1 argument to MSBuild and declaring all other projects as Dependencies of Wix Project: i.e. in VS, PROJECT –> Project Dependencies. This caused MsBuild to build all other projects before Wix Project and now Wix is able to find its Source files properly…
Here is the screenshot for illustration:

Adding files to the bin directory at Build and Publish

I have two license files that I would like to include in my \bin directory both when I build and publish.
Both files are in the App_Data directory (their initial location doesn't matter, they just need to end up in the \bin) and have the following properties set:
Build Action = Content
Copy to Output Directory = Copy Always
They are in not the \bin when I build or publish.
What is wrong with my setup: the settings, the folders, the files, something else...?
UPDATE
I moved the files out of the App_Data directory and placed them in the project root and now they are copied to the \bin on build.
I've done this in a few projects by expanding my .csproject file slightly. The following code should be put directly beneath the Project node in your WebProject.csproj.
The AfterBuild target simply copies a set of files ("unreferenced DLLs" in this case) to the bin-folder when building normally from Visual Studio. The CustomCollectFiles basically do the same thing when deploying.
<PropertyGroup>
<UnreferencedDlls>..\lib\Unreferenced\**\*.dll</UnreferencedDlls>
</PropertyGroup>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="AfterBuild">
<Message Text="Copying unreferenced DLLs to bin" Importance="High" />
<CreateItem Include="$(UnreferencedDlls)">
<Output TaskParameter="Include" ItemName="_UnReferencedDLLs" />
</CreateItem>
<Copy SourceFiles="#(_UnReferencedDLLs)" DestinationFolder="bin\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>
<Target Name="CustomCollectFiles">
<Message Text="Publishing unreferenced DLLs" Importance="High" />
<ItemGroup>
<_CustomFiles Include="$(UnreferencedDlls)" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
The part you need to modify is basically the UnreferencedDlls node to match your folder structure. The **\*.dll part simply means "every DLL file at any level beneath here".
If you're using Visual Studio:
Show your file properties (Click on your file or Right-click on it then choose Properties)
At the Copy to Output Directory property choose Copy always or Copy if newer.
At build time, the file is going to be copied at the bin directory: Debug or Release...
not necessarily a direct answer, but I highly suggest not using the baked in "publish" mechanism, but rather wire up a build script (probably in powershell) that will do everything you need. It's really easy to hook into MSBuild as well as nUnit and also copy files and move them around.
POWERSHELL (rough) example.
# Get Directory Location
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
# Build the application using MSBuild
cmd /c C:\Windows\Microsoft.NET\Framework\$v4_net_version\msbuild.exe "$directorypath\MyProject.sln" /p:Configuration=Release
# Run the tests using nUnit
cmd /c $directorypath\build\nunit\nunit-console.exe $solutionPath\MyProject.Tests\bin\debug\MyProject.Tests.dll
# Copy the license to the appropriate directory
Copy-Item -LiteralPath "$directorypath\mylicensefile.txt" "$directorypath\bin\release" -Force
# NOTE: You are going to have to adjust this to match your solution and projects.
In this post on Microsoft Connect the answer is much simpler:
Referenced assemblies in Unit Test are not copied in TestResults/Out
So what I did was the following:
[TestClass]
[DeploymentItem("Some.dll")]
public class SomeTests
{
...
}
It works fine for me.
Hope it help.

MSBuild Message Output Twice

I have the following Target:
<Target Name="SetBinariesLocationForTeamBuild">
<!--We add the following location paths because TFS Team Build first copies to \sources and \binaries folders
rather than simply having the binaries in a \bin folder of the source folder
at this point the build will be at: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment
so we need to go up 4 levels before going back down to binaries-->
<Message Text="Value of TeamBuild=$(TeamBuild)"/>
<Message Text="MSBuildProjectName: $(MSBuildProjectName)"/>
<Message Text="MSBuildStartupDirectory: $(MSBuildStartupDirectory)"/>
<Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/>
<Message Text="MSBuildProjectFullPath: $(MSBuildProjectFullPath)"/>
<Message Text="MSBuildThisFileDirectory: $(MSBuildThisFileDirectory)"/>
<ItemGroup>
<Schemas Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.MIS.Schemas.dll">
<LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath>
</Schemas>
</ItemGroup>
<ItemGroup>
<Pipelines Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.Pipelines.dll">
<LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath>
</Pipelines>
</ItemGroup>
<ItemGroup>
<PipelineComponents Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.PipelineComponents.dll">
<LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath>
</PipelineComponents>
</ItemGroup>
<ItemGroup>
<Orchestrations Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.Orchestrations.dll">
<LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath>
</Orchestrations>
</ItemGroup>
<ItemGroup>
<Transforms Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.Transforms.dll">
<LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath>
</Transforms>
</ItemGroup>
<Message Text="What is Schemas location path: %(Schemas.LocationPath)"/>
<Message Text="What is Pipelines location path: %(Pipelines.LocationPath)"/>
</Target>
I run the project from the command line passing in /p:TeamBuild=True /t:SetBinariesForTeamBuild. The output has me very puzzled...
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.269]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 24/07/2012 16:59:08.
Project "C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\x.Int.MIS.Deployment.btdfproj" on node 1 (SetBinariesLocationForTeamBuild target(s)).
SetBinariesLocationForTeamBuild:
Value of TeamBuild=True
MSBuildProjectName: x.Int.MIS.Deployment
MSBuildStartupDirectory: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment
MSBuildProjectDirectory: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment
MSBuildProjectFullPath: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\x.Int.MIS.Deployment.btdfproj
MSBuildThisFileDirectory: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\
What is Schemas location path: ..\x.Int.MIS.Schemas\bin\Debug
What is Schemas location path: ..\..\..\..\..\..\..\..\binaries\
What is Pipelines location path: ..\x.Int.MIS.Pipelines\bin\Debug
What is Pipelines location path: ..\..\..\..\..\..\..\..\binaries\
Done Building Project "C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\x.Int.MIS.Deployment.btdfproj" (SetBinariesLocationForTeamBuild target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.17
I want the location path to be the one with 8 ..\ but it is not - any idea why and why it gets printed twice!?
The #(Schemas) and #(Pipelines) item arrays are each getting another item tuple added to them, or else they couldn't be printing out. There must be another target that is getting run in which this happens. If you are running msbuild on the project using the exact command line, then the additional target would have to be either an entry in an InitialTargets on a Project, or else a target wired into the target above with a BeforeTargets or AfterTargets reference to this one.

Resources