Trouble with MSBuild and setting a target framework for vbc migrating from asp.net 2.0 to .net 4.5.1

resourcesys
resourcesys used Ask the Experts™
on
Hello,

We have an application developed in ASP.NET 2.0 which we now want to compile in ASP.NET 4.5.1.

The application consists of a visual studio 2005 solution (a collection of class libraries) and  individual code behind files, not a part of a website project.

It is compiled via a command file that calls MSBuild running a .proj file (code follows)

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

  <!--======================================================================================================================= -->
  
	<PropertyGroup>
		<ProjectDir>$(MSBuildProjectDirectory)</ProjectDir>
	</PropertyGroup>
  
  <PropertyGroup>
    <SvnRepoPath>svn://Repository/Application/trunk</SvnRepoPath>
    <SvnUsername>user</SvnUsername>
    <SvnPassword>pass</SvnPassword>
  </PropertyGroup>
 
  <!--If the configuration is not passed in from the command prompt then we default it to debug -->
  <PropertyGroup>
    <Configuration Condition="$(Configuration) == '' ">Release</Configuration>
  </PropertyGroup>
  
  <!-- Set up and default the version properties -->
  <PropertyGroup>
		<Major>4</Major>
		<Minor>3</Minor>
		<Build>2</Build>
		<Revision>1</Revision>
	</PropertyGroup>

  <!--======================================================================================================================= -->
  
  <Target Name="VersionSetup" >

  <Time Format="yy">
    <Output TaskParameter="FormattedTime" PropertyName="Minor" />
  </Time>

  <Time Format="ddMM">
    <Output TaskParameter="FormattedTime" PropertyName="Build" />
  </Time>

  <Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>

  <AssemblyInfo CodeLanguage="VB"
        OutputFile="$(ProjectDir)\ClassLibriaries\AssemblyInfo.vb"
        AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
        AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"
        Condition="$(Revision) != '0' "/>

  <AssemblyInfo CodeLanguage="VB"
        OutputFile="$(ProjectDir)\Include\AssemblyInfo.vb"
        AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
        AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"
        AssemblyTitle="Application"
        AssemblyDescription="$(SvnRepoPath)"
        Guid="3d5900ae-111a-45be-96b3-d9e4606ca793"
        Condition="$(Revision) != '0' "/>

  <Message Text="Version set up"/>
    
  </Target>
  
  <!--======================================================================================================================= -->
  
	<Target Name="Build" DependsOnTargets="VersionSetup">

    <CreateItem Include="$(ProjectDir)\ClassLibraries\">
      <Output TaskParameter="Include" ItemName="TargetOutputsDirectory"/>
    </CreateItem>

    <MSBuild Projects="$(ProjectDir)\ClassLibraries\ClassLibraries.sln" Targets="Clean;ReBuild" Properties="Configuration=$(Configuration);OutDir=$(ProjectDir)\bin\" StopOnFirstFailure="false" ContinueOnError="true">
      <Output TaskParameter="TargetOutputs" ItemName="@(TargetOutputsDirectory)" />
    </MSBuild>

    <Exec Command='CompileAll.bat' WorkingDirectory='$(ProjectDir)\Application' />
    <Exec Command='CompileAll.bat' WorkingDirectory='$(ProjectDir)\Application\Reports' />

    <Message Text="Build completed"/>
    
	</Target>
  
  <!--======================================================================================================================= -->

</Project>

Open in new window


When the solution is built in vs2013 with the target framework set to .net 4.5.1 it compiles fine but when running the command file the following error occurs:

error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutputs" parameter. The name "D:\DotNet451\ClassLibriaries\" contains an invalid character ":".

A second issue is that the codebehind files are compiles via a command file that calls vbc in the .net 4 directory. Is there a way to get it to specifically compile in .net 4.5.1? The files do compile but I do not know what framework they are compiled against. Also, the following warning is displayed:

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to Visual Basic 2012, which is no longer the latest version. For compilers that support newer versions of the Visual Basic programming language, see http://go.microsoft.com/fwlink/?LinkID=533241

Any help/suggestions are much appreciated.

resourcesys.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015

Commented:
D:\DotNet451\ClassLibriaries\

You have an extra i before the a in Libraries

For the second problem, are you sure that the vbc.exe file you are calling is the proper version? VS2013 can be installed with framework 4.5.2 and you seem to use a vbc that targets a previous version.
Top Expert 2016

Commented:
why don't you download and install Visual Studio Community ?

Author

Commented:
Thanks for the replies guys.

I fixed the spelling mistake but still get the invalid character error message.

To be honest I don't know which vbc to point to, I just need one that will compile to asp.net 4.5.1

What difference will visual studio community make? I have 2015 pro if that helps?

But this all still needs to go through a command file as it is part of an automated build process.

Thanks.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Author

Commented:
I have pointed to the VBC in the MSBuild\12.0\bin directory which I believe covers .net 4.5.1. The code behind files are building without any warnings.

I have pointed to the sme directory for MSBuild to compile the solution but still have the issue with the colon character being invalid.
Top Expert 2016

Commented:
what is the content of CompileAll.bat

Author

Commented:
The CompileAll.bat file loops though all code behind files in a directory and compiles them. This is working fine since pointing to the version 12 vbc directory.
I have adjusted the .proj file and commented out the <Output TaskParameter="TargetOutputs" ItemName="@(TargetOutputsDirectory)" /> line in the MSBuild tags.

This is allowing the code to build and the .dll files are being generated correctly.

I am not sure of the function of this code but obviously it appears to be redundant.


So in summary, to take care of my issues, I pointed to a different directory for MSBuild and VBC. Also, I commented out a redundant line from the .proj file.

Author

Commented:
Steps taken in my "solution" have solved my initial issues

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial