Azure Web Job: msbuild: How to publish without Debug DLLs? - msbuild

I have a Visual Studio solution comprising an Azure web app and some Azure web jobs. I have a command line script to publish an Azure web job. My problem is that the publish script builds the software and pulls in Debug DLLs instead of Release DLLs.
> msbuild.exe "c:\git\2\Code\Server\Jobs\Azure\My.Web.Jobs.Number1Script.WebJob\My.Web.Jobs.Number1Script.WebJob.csproj" /p:DeployOnBuild=true /p:PublishProfile="qa-My-sanity - Web Deploy" /p:VisualStudioVersion=14.0 /p:Password="password" /verbosity:minimal /filelogger /flp:logfile=number1_development.log
I think that the solution file My.sln contains information about various compile configurations, but they are not in the .csproj file.
How can I configure my publish such that Debug DLLs are not pulled into the published software?
The My.Web.Jobs.Number1Script.WebJob.csproj file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1EEB8236-718C-4860-BE73-0E95CB3ABC82}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>My.Web.Jobs.Number1Script.WebJob</RootNamespace>
<AssemblyName>My.Web.Jobs.Number1Script.WebJob</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Certificates\My Corporation.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.WebJobs, Version=1.0.1.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Azure.WebJobs.Core.1.0.1\lib\net45\Microsoft.Azure.WebJobs.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.WebJobs.Host, Version=1.0.1.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Azure.WebJobs.1.0.1\lib\net45\Microsoft.Azure.WebJobs.Host.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\WindowsAzure.Storage.4.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Functions.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\PublishProfiles\qa-My - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\qa-My-sanity - Web Deploy.pubxml" />
<None Include="Properties\webjob-publish-settings.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\My.Web.Jobs.Number1Script\My.Web.Jobs.Number1Script.csproj">
<Project>{2c99c938-4a66-4bb9-a237-3192428f5618}</Project>
<Name>My.Web.Jobs.Number1Script</Name>
</ProjectReference>
<ProjectReference Include="..\..\My.Web.Jobs\My.Web.Jobs.csproj">
<Project>{b1c602b2-7cb4-489b-9dec-a920f963c8e1}</Project>
<Name>My.Web.Jobs</Name>
</ProjectReference>
<ProjectReference Include="..\My.Web.Jobs.WebJob\My.Web.Jobs.WebJob.csproj">
<Project>{a2c68e89-a4eb-4a07-b8da-384010914104}</Project>
<Name>My.Web.Jobs.WebJob</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<Import Project="..\..\..\..\packages\Microsoft.Web.WebJobs.Publish.1.0.9\tools\webjobs.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebJobs.Publish.1.0.9\tools\webjobs.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
When I publish the job through Visual Studio, I have a build configuration called "Release - Azure". I can do a pure build (no publish) using this line:
> msbuild.exe "c:\git\2\Code\My.sln" /fileLogger /verbosity:minimal /p:Configuration='Release - Azure'
When I do that, the code is built, and Debug DLLs are not pulled in. But if I publish using the .csproj file, the Debug DLLs get pulled in.
I also tried the publish command using the same command, but suffixed with:
/p:Configuration=Release
That gave errors. I tried:
/p:Configuration="Release - Azure"
That gave errors too.
In my My.sln file, I have lines relating to "Release - Azure". They look like this:
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Local|Any CPU = Local|Any CPU
Local|x64 = Local|x64
Local|x86 = Local|x86
Release - Azure|Any CPU = Release - Azure|Any CPU
Release - Azure|x64 = Release - Azure|x64
Release - Azure|x86 = Release - Azure|x86
Release - Windows|Any CPU = Release - Windows|Any CPU
Release - Windows|x64 = Release - Windows|x64
Release - Windows|x86 = Release - Windows|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
There are lots of sections which look like:
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxxx}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x64.ActiveCfg = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x64.Build.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x64.Deploy.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x86.ActiveCfg = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x86.Build.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x86.Deploy.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|Any CPU.ActiveCfg = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|Any CPU.Build.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|Any CPU.Deploy.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x64.ActiveCfg = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x64.Build.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x64.Deploy.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x86.ActiveCfg = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x86.Build.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x86.Deploy.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|Any CPU.ActiveCfg = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|Any CPU.Build.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|Any CPU.Deploy.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x64.ActiveCfg = Release|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x64.Build.0 = Release|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x64.Deploy.0 = Release|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x86.ActiveCfg = Release|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x86.Build.0 = Release|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x86.Deploy.0 = Release|x86
...
EndGlobalSection
My .pubxml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release - Azure</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://qa-My-sanity.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<MSDeployServiceURL>qa-My-sanity.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>qa-My__sanity</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<UserName>$qa-My__sanity</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
</PropertyGroup>
</Project>

/p:PublishProfile="qa-My-sanity - Web Deploy"
In the publish profiles file, there is a property named LastUsedBuildConfiguration which will specify the build version. Please change it to any build version you want.
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>

Related

Setting OutputName from wxi MSBUILD -Customizing Target Order

I'm trying to set the <OutputName> of my .msi when using Wix in VisualStudio.
I have seen the other questions related to this, but I am approaching it a bit differently. Hoping you can all clear up some things for me.
This is my .wixproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>fa14</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>Installer_x64_v$(Version)</OutputName>
<OutputType>Package</OutputType>
<!--<ProjectGuid>{fa1414f5-97eb-4d39-8ff6-190cd92ca99f}</ProjectGuid>-->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<WixVariables>
</WixVariables>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
<Compile Include="Files.wxs" />
<Compile Include="UI.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
</Target>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
</PropertyGroup>
<Target Name="BeforeBuild">
<ReadLinesFromFile File="Configuration.wxi" >
<Output TaskParameter="Lines" PropertyName="FileContents"/>
</ReadLinesFromFile>
<PropertyGroup>
<!-- Find occurence of string ProductVersion, return everything after 'Productversion', trimming spaces and " -->
<TrimmedWXI>$(FileContents.Substring($(FileContents.IndexOf(ProductVersion))).Replace(" ","").Replace('"',""))</TrimmedWXI>
<!-- Find the equals sign, add 1-->
<VersionStart>$([MSBuild]::Add($(TrimmedWXI.IndexOf(=)),1))</VersionStart>
<!-- Find the ?-->
<VersionEnd>$(TrimmedWXI.IndexOf(?))</VersionEnd>
<!-- Find the length of the version-->
<VersionLength>$([MSBuild]::Subtract($(VersionEnd),$(VersionStart)))</VersionLength>
<!-- Find the version-->
<Version>$(TrimmedWXI.Substring($(VersionStart),$(VersionLength)))</Version>
</PropertyGroup>
<Message Importance="High" Text=" Attempting build for $(Version)" />
</Target>
<Target Name="AfterBuild">
<Message Importance="High" Text="BuildDone" />
</Target>
</Project>
And the configuration.wxi
<?xml version="1.0" encoding="utf-8"?>
<Include>
<!-- Setup Configuration -->
<?define ProductName = "Acme" ?>
<?define ProductManufacturer = "AcmeInc." ?>
<?define ProductVersion = "9.99" ?>
<?define ProductUpgradeCode = "FAKEGUID" ?>
</Include>
Now, I am setting the <Version> property appropriately, it parses the file string properly and spits it out in the message, but when it comes to the building of the .msi, it is still blank. Looks like Version gets set after the OutputName is set, and I cant overwrite or make Version set before the OutputName.
I've done some reading and messed around with the Target and build order, but I can't quite get anything to work.
It seems like the OutputName is required to be set before everything else?
Why doesn't this get overridden in the BeforeBuild target?
Is it possible to have this ReadLinesFromFile task happen before the OutputName is set?
Thanks!

How to use Wix binaries on Build machine

I am setting up wix without installing on build machine by keeping Wix binaries in the source code directory itself. When i configure the wixproj file based on the steps mentioned in the wix website
<PropertyGroup>
<WixToolPath>$(SourceCodeControlRoot)\wix\[[Version]]\</WixToolPath>
<WixTargetsPath>$(WixToolPath)Wix.targets</WixTargetsPath>
<WixTasksPath>$(WixToolPath)wixtasks.dll</WixTasksPath>
</PropertyGroup>
, it is not locating the local binary files When i change the WixTarget paths to local directory because in Wix.tagets file has the follwing
<?xml version="1.0" encoding="utf-8"?>
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- All common targets/items/properties -->
<!-- Version specific targets/items/properties -->
<PropertyGroup>
<WixTargetsImported>true</WixTargetsImported>
<!-- MSBuild 4.0 -->
<!-- MSBuild does not do short circuit evaluation of the AND operator, so we cannot have
something like '$(MSBuildToolsVersion)' != '' AND '$(MSBuildToolsVersion)' >= '4.0'
instead set as default and override -->
<WixVersionTargetsPath>wix2010.targets</WixVersionTargetsPath>
<!-- MSBuild 2.0 - 3.5 -->
<WixVersionTargetsPath Condition=" '$(MSBuildToolsVersion)' == '' OR '$(MSBuildToolsVersion)' < '4.0' ">wix200x.targets</WixVersionTargetsPath>
</PropertyGroup>
<Import Project="$(WixVersionTargetsPath)" />
</Project>
commands which invokes wix2010.targets.
In wix2010.targets,
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="Build"
InitialTargets="_CheckForInvalidConfigurationAndPlatform;
_CheckRequiredProperties">
<PropertyGroup>
<WixInstallPath Condition=" '$(WixInstallPath)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Installer XML\3.11#InstallRoot)</WixInstallPath>
<WixInstallPath Condition=" '$(WixInstallPath)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows Installer XML\3.11#InstallRoot)</WixInstallPath>
</PropertyGroup>
<!--
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
Extension Points
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
-->
<!-- Allow a user-customized targets files to be used as part of the build. -->
<PropertyGroup>
<UserTargetsPath>$(MSBuildProjectFullPath).user</UserTargetsPath>
</PropertyGroup>
<Import Project="$(UserTargetsPath)" Condition="Exists('$(UserTargetsPath)')" />
<Import Project="$(CustomBeforeWixTargets)" Condition=" '$(CustomBeforeWixTargets)' != '' and Exists('$(CustomBeforeWixTargets)')" />
<!-- These properties can be overridden to support non-default installations. -->
<PropertyGroup>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixInstallPath)\WixTasks.dll</WixTasksPath>
<LuxTargetsPath Condition=" '$(LuxTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Lux.targets</LuxTargetsPath>
<LuxTargetsPath Condition=" '$(LuxTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Lux.targets</LuxTargetsPath>
<LuxTasksPath Condition=" '$(LuxTasksPath)' == '' ">$(WixInstallPath)\LuxTasks.dll</LuxTasksPath>
</PropertyGroup>
<!-- This makes the project files a dependency of all targets so that things rebuild if they change -->
<PropertyGroup>
<MSBuildAllProjects Condition="Exists('$(MSBuildProjectFullPath)')">$(MSBuildAllProjects);$(MSBuildProjectFullPath)</MSBuildAllProjects>
<MSBuildAllProjects Condition="Exists('$(WixTargetsPath)')">$(MSBuildAllProjects);$(WixTargetsPath)</MSBuildAllProjects>
<MSBuildAllProjects Condition="Exists('$(LuxTargetsPath)')">$(MSBuildAllProjects);$(LuxTargetsPath)</MSBuildAllProjects>
<MSBuildAllProjects Condition="Exists('$(UserTargetsPath)')">$(MSBuildAllProjects);$(UserTargetsPath)</MSBuildAllProjects>
<MSBuildAllProjects Condition="Exists('$(CustomBeforeWixTargets)')">$(MSBuildAllProjects);$(CustomBeforeWixTargets)</MSBuildAllProjects>
<MSBuildAllProjects Condition="Exists('$(CustomAfterWixTargets)')">$(MSBuildAllProjects);$(CustomAfterWixTargets)</MSBuildAllProjects>
</PropertyGroup>
<!--
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
Property Declarations
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
-->
<!-- These tasks can be used as general-purpose build tasks. -->
<UsingTask TaskName="Candle" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="Insignia" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="Lit" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="Light" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="Torch" AssemblyFile="$(WixTasksPath)" />
<!-- These tasks are extensions for harvesting WiX source code from other sources. -->
<UsingTask TaskName="HeatFile" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="HeatDirectory" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="HeatProject" AssemblyFile="$(WixTasksPath)" />
<!-- These tasks are specific to the build process defined in this file, and are not considered general-purpose build tasks. -->
<UsingTask TaskName="AssignProjectConfiguration" AssemblyName="Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="AssignTargetPath" AssemblyName="Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="ResolveNonMSBuildProjectOutput" AssemblyName="Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="ResolveVCProjectOutput" AssemblyName="Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="CreateItemAvoidingInference" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="CreateProjectReferenceDefineConstants" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="WixAssignCulture" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="ResolveWixReferences" AssemblyFile="$(WixTasksPath)"/>
<UsingTask TaskName="ReplaceString" AssemblyFile="$(WixTasksPath)"/>
<UsingTask TaskName="GetCabList" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="GetLooseFileList" AssemblyFile="$(WixTasksPath)" />
<UsingTask TaskName="RefreshGeneratedFile" AssemblyFile="$(WixTasksPath)"/>
<UsingTask TaskName="RefreshBundleGeneratedFile" AssemblyFile="$(WixTasksPath)"/>
<UsingTask TaskName="GenerateCompileWithObjectPath" AssemblyFile="$(WixTasksPath)"/>
<!-- WiX tools are 32bit EXEs, so run them out-of-proc when MSBuild is not 32bit. -->
<PropertyGroup>
<RunWixToolsOutOfProc Condition=" '$(PROCESSOR_ARCHITECTURE)'!='x86' ">true</RunWixToolsOutOfProc>
</PropertyGroup>
<!--
Several properties must be set in the main project file, before using this .targets file.
However, if the properties are not set, we pick some defaults.
OutDir:
Indicates the final output location for the project or solution. When building a solution,
OutDir can be used to gather multiple project outputs in one location. In addition,
OutDir is included in AssemblySearchPaths used for resolving references.
OutputPath:
This property is usually specified in the project file and is used to initialize OutDir.
OutDir and OutputPath are distinguished for legacy reasons, and OutDir should be used if at all possible.
BaseIntermediateOutputPath:
This is the top level folder where all configuration specific intermediate output folders will be created.
Default value is obj\
IntermediateOutputPath:
This is the full intermediate Output Path, and is derived from BaseIntermediateOutputPath, if none specified
(eg. obj\debug). If this property is overridden, then setting BaseIntermediateOutputPath has no effect.
-->
<PropertyGroup>
<!-- Ensure any OutputPath has a trailing slash, so it can be concatenated -->
<OutputPath Condition="'$(OutputPath)' != '' and !HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath>
<AssemblyName Condition=" '$(AssemblyName)'=='' ">$(MSBuildProjectName)</AssemblyName>
<!--
Be careful not to give OutputPath a default value in the case of an invalid Configuration/Platform.
We use OutputPath specifically to check for invalid configurations/platforms.
-->
<OutputPath Condition=" '$(Platform)'=='' and '$(Configuration)'=='' and '$(OutputPath)'=='' ">bin\Debug\</OutputPath>
<_OriginalConfiguration>$(Configuration)</_OriginalConfiguration>
<_OriginalPlatform>$(Platform)</_OriginalPlatform>
<Configuration Condition=" '$(Configuration)'=='' ">Debug</Configuration>
<ConfigurationName Condition=" '$(ConfigurationName)' == '' ">$(Configuration)</ConfigurationName> <!-- Example, Debug -->
<Platform Condition=" '$(Platform)'=='' ">AnyCPU</Platform>
<_OriginalOutputType>$(OutputType)</_OriginalOutputType>
<OutputType Condition=" '$(OutputType)' == '' ">Package</OutputType>
<BuildProjectReferences Condition="'$(BuildProjectReferences)' == ''">true</BuildProjectReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(OutputPath)' == '' ">
<!--
A blank OutputPath at this point means that the user passed in an invalid Configuration/Platform
combination. Whether this is considered an error or a warning depends on the value of
$(SkipInvalidConfigurations).
-->
<_InvalidConfigurationError Condition=" '$(SkipInvalidConfigurations)' != 'true' ">true</_InvalidConfigurationError>
<_InvalidConfigurationWarning Condition=" '$(SkipInvalidConfigurations)' == 'true' ">true</_InvalidConfigurationWarning>
</PropertyGroup>
<!-- Properties for the intermediate object output -->
<PropertyGroup>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition="!HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
<IntermediateExt Condition=" '$(IntermediateExt)' == '' ">.wixobj</IntermediateExt>
<CleanFile Condition=" '$(CleanFile)' == '' ">$(MSBuildProjectFile).FileList.txt</CleanFile>
<BindContentsFilePrefix Condition=" '$(BindContentsFilePrefix)' == '' ">$(MSBuildProjectFile).BindContentsFileList</BindContentsFilePrefix>
<BindContentsFileExtension Condition=" '$(BindContentsFileExtension)' == '' ">.txt</BindContentsFileExtension>
<BindOutputsFilePrefix Condition=" '$(BindOutputsFilePrefix)' == '' ">$(MSBuildProjectFile).BindOutputsFileList</BindOutputsFilePrefix>
<BindOutputsFileExtension Condition=" '$(BindOutputsFileExtension)' == '' ">.txt</BindOutputsFileExtension>
<BindBuiltOutputsFilePrefix Condition=" '$(BindBuiltOutputsFilePrefix)' == '' ">$(MSBuildProjectFile).BindBuiltOutputsFileList</BindBuiltOutputsFilePrefix>
<BindBuiltOutputsFileExtension Condition=" '$(BindBuiltOutputsFileExtension)' == '' ">.txt</BindBuiltOutputsFileExtension>
<SignedFile Condition=" '$(SignedFile)' == '' ">$(MSBuildProjectFile).Signed.txt</SignedFile>
</PropertyGroup>
<PropertyGroup Condition=" $(IntermediateOutputPath) == '' ">
<IntermediateOutputPath Condition=" '$(PlatformName)' == 'AnyCPU' ">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition=" '$(PlatformName)' != 'AnyCPU' ">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<IntermediateOutputPath Condition="!HasTrailingSlash('$(IntermediateOutputPath)')">$(IntermediateOutputPath)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<CabinetCachePath Condition=" '$(CabinetCachePath)'=='' and '$(ReuseCabinetCache)'=='true' ">$(IntermediateOutputPath)cabcache\</CabinetCachePath>
</PropertyGroup>
<ItemGroup>
<IntermediateAssembly Include="$(IntermediateOutputPath)$(TargetName)$(TargetExt)"/>
<FinalDocFile Include="#(DocFileItem->'$(OutDir)%(Filename)%(Extension)')"/>
</ItemGroup>
<PropertyGroup>
<WixToolPath Condition=" '$(WixToolPath)' == ''">$(WixInstallPath)</WixToolPath>
<WixExtDir Condition=" '$(WixExtDir)' == ''">$(WixToolPath)</WixExtDir>
</PropertyGroup>
</Project>
it is looking C:\programfiles directory to invoke light.exe, heat.exe and all
How do i point the local wix files dirctory in wix2010.targets to run wix projects.
Previously I had configured:
<WixTargetsPath>$(SourceCodeControlRoot)\wix\[[Version]]\Wix.targets</WixTargetsPath>
<WixTasksPath>$(SourceCodeControlRoot)\wix\[[Version]]\wixtasks.dll</WixTasksPath>
Then I changed as per the document i.e I added:
<WixToolPath>$(SourceCodeControlRoot)\wix\[[Version]]\</WixToolPath>
into the property group.
Once added, everything works fine.

Not able to Transform T4 Template using MSBUILD toolset="16.0"

I'm Trying to Transform T4 Template using MSBUILD , but I'm getting the following error
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\TextTemplating\Micro
soft.TextTemplating.targets(224,5): error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the asse
mbly "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Tasks.Cores.dll
". Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Curre
nt\Bin\Microsoft.Build.Tasks.Cores.dll' or one of its dependencies. The system cannot find the file specified. [E:\csha
rpprojects\Automateodessa\Automateodessa\Automateodessa.csproj]
My .tt file content
<## template debug="false" hostspecific="false" language="C#" #>
<## assembly name="System.Core" #>
<## import namespace="System.Linq" #>
<## import namespace="System.Text" #>
<## import namespace="System.Collections.Generic" #>
<## output extension=".txt" #>
<#
for(int i = 0; i < 10; i++)
WriteLine($"Hello World {i}");
#>
Hello$(classname)
My .csproj file content
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="16.0">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<builtdir>E:\BuiltApp</builtdir>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{58C4A28E-C37D-4D95-BBEE-6427A3F3129D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Automateodessa</RootNamespace>
<AssemblyName>Automateodessa</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<T4ParameterValues Include="classname">
<Value>asdsd</Value>
<Visible>False</Visible>
</T4ParameterValues>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Content Include="TextTemplate1.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>TextTemplate1.txt</LastGenOutput>
</Content>
<Resource Include="TextTemplate1.txt">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>TextTemplate1.tt</DependentUpon>
</Resource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets" />
<Target Name="AfterBuild">
<Message Text="The output file is hhahah" />
</Target>
</Project>
And my command for MSbuild is
MSBuild.exe E:\csharpprojects\Automateodessa\Automateodessa\Automateodessa.csproj /t:Transform /p:TransformFile="TextTemplate1.tt"
Can Someone tell me why am I getting this error?
P.S
My MSBUILD Variable got by /v:diag
MSBuildBinPath = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
MSBuildExtensionsPath = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild
MSBuildExtensionsPath32 = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild
MSBuildExtensionsPath64 = C:\Program Files\MSBuild
MSBuildFrameworkToolsPath = C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\
MSBuildFrameworkToolsPath32 = C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\
MSBuildFrameworkToolsPath64 = C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\
MSBuildFrameworkToolsRoot = C:\WINDOWS\Microsoft.NET\Framework\
MSBuildLoadMicrosoftTargetsReadOnly = true
MSBuildNodeCount = 1
MSBuildProgramFiles32 = C:\Program Files (x86)
MSBuildProjectDefaultTargets = Build
MSBuildProjectDirectory = E:\csharpprojects\StudySnippets
MSBuildProjectDirectoryNoRoot = csharpprojects\StudySnippets
MSBuildProjectExtension = .csproj
MSBuildProjectExtensionsPath = E:\csharpprojects\StudySnippets\obj\
MSBuildProjectFile = Testing.csproj
MSBuildProjectFullPath = E:\csharpprojects\StudySnippets\Testing.csproj
MSBuildProjectName = Testing
MSBuildRuntimeType = Full
MSBuildRuntimeVersion = 4.0.30319
MSBuildSDKsPath = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Sdks
MSBuildStartupDirectory = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
MSBuildToolsPath = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
MSBuildToolsPath32 = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
MSBuildToolsPath64 = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64
MSBuildToolsRoot = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild
MSBuildToolsVersion = Current
MSBuildUserExtensionsPath = C:\Users\admin\AppData\Local\Microsoft\MSBuild
MSBuildVersion = 16.2.37902
MsTestToolsTargets = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0
\TeamTest\Microsoft.TeamTest.targets
NetFrameworkPropsPath = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.NET
Framework.CurrentVersion.props
NetFrameworkTargetsPath = C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.N
ETFramework.CurrentVersion.targets```
Not able to Transform T4 Template using MSBUILD toolset=“16.0”
I think you just use msbuild.exe from an old framework or just use an old version of MSBuild like VS2017. Since you have set MSBUILD toolset="16.0", it means that you should use MSBuild v16.0 to build your project.
1) Please use C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe rather than any other old version of MSBuild.exe
2) just use Developer Command Prompt for VS2019
Update 1
Besides, if you still face the issue after the solution, I think there are something wrong with your project or VS Environment.
Solution
1) I think you have create a new VS2019 project and then migrate the old project into it to test whether it is your old project's problem.
2) Please do a repair in VS Installer or update your VS to the latest version to test whether it is the issue of your VS Environment.
Hope this could help you.

naming a configuration property function

I have a project that has a set of project contexts (full property groups omitted for brevity):
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'v82_Release|x64' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'v90_Release|x64' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'v90_Debug|x64' ">
The referenced assemblies vary by the version number at the beginning of the configuration
variable, so I opened the VS-generated csproj file and edited the references (parent Reference items omitted for brevity):
<HintPath>Lib\$(Configuration.Substring(0,3))\Assembly1.dll</HintPath>
<HintPath>Lib\$(Configuration.Substring(0,3))\Assembly2.dll</HintPath>
<HintPath>Lib\$(Configuration.Substring(0,3))\Assembly3.dll</HintPath>
This works, but is there a way to effectively define $(LibVersionNum) = $(Configuration.Substring(0,3)) and thus clean up my syntax?
Try this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>v82_Release</Configuration>
<Platform>x64</Platform>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'v82_Release|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'v90_Release|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'v90_Debug|x64' ">
</PropertyGroup>
<PropertyGroup>
<LibVersionNum>$(Configuration.Substring(0,3))</LibVersionNum>
</PropertyGroup>
<ItemGroup>
<MyItem Include="Ref1">
<HintPath>Lib\$(LibVersionNum)\Assembly1.dll</HintPath>
</MyItem>
<MyItem Include="Ref2">
<HintPath>Lib\$(LibVersionNum)\Assembly2.dll</HintPath>
</MyItem>
<MyItem Include="Ref3">
<HintPath>Lib\$(LibVersionNum)\Assembly3.dll</HintPath>
</MyItem>
</ItemGroup>
<Target Name="Build">
<Message Text="Current Config: $(Configuration)"/>
<Message Text="%(MyItem.Identity): %(MyItem.HintPath)"/>
</Target>
</Project>

Project-level conditional compilation constant

I am getting a project-level conditional compilation constant error while trying to build my VB.NET project. It reads:
project-level conditional compilation constant 'VB_VER=9.0,TARGET="exe",CONFIG="Debug",_MyType="Console",PLATFORM="AnyCPU",DEBUG;^^ ^^ TRACE' not valid: Character is not valid.
I recently upgraded it to the latest version (from 2.0), and I have a feeling that this has something to do with it.
What does this mean? I am clueless...
Here is my project file:
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>local</ProjectType>
<ProjectVersion>7.10.3077</ProjectVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5810CBEF-671E-4845-BBE3-BC3470C3EE18}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<AssemblyName>svchost</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Exe</OutputType>
<FileUpgradeFlags>
</FileUpgradeFlags>
<MyType>Console</MyType>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<StartupObject>Sub Main</StartupObject>
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>svchost.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<NoStdLib>false</NoStdLib>
<Optimize>false</Optimize>
<WarningLevel>4</WarningLevel>
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>svchost.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>false</DebugSymbols>
<NoStdLib>false</NoStdLib>
<Optimize>true</Optimize>
<WarningLevel>4</WarningLevel>
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<ItemGroup>
<!-- Removed Files Here -->
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
I had the same problem. But after I used "," as the separating character between constants instead of ";", it worked.
So have a try with "," (comma) only.
I changed the DefineConstants tag in this block:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>svchost.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<NoStdLib>false</NoStdLib>
<Optimize>false</Optimize>
<WarningLevel>4</WarningLevel>
<NoWarn>42016,42017,42018,42019,42032</NoWarn>
<DebugType>full</DebugType>
</PropertyGroup>
to
<DefineConstants>DEBUG</DefineConstants>
It worked like a charm!
In .vbproj files you must delimit define constants with commas, unlike the semicolons used in .csproj files. So if you want DEBUG and TRACE flags you want:
<DefineConstants>DEBUG,TRACE</DefineConstants>