Msbuild doubt about compilation C#

Asked

Viewed 130 times

0

Hello, I have a project in C# windows Forms and I need to compile and generate the .exe with Msbuild. However, when I update the sources and run to compile, it gives error saying that the structure of the code is wrong: with dot and comma missing, etc.
But if I get into the same project, compile from the Visual Studio IDE, and then go do it from Msbuild, it works smoothly. In my case I need to compile where the IDE is not installed.

Thank you very much.

Build error message with MSBUILD :

"D:\CRIS\Programas_Cris\Projeto\Projeto.sln" (destino padrão) (1) ->"D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj" (destino padrão) (2) ->
  (CoreCompile destino) ->  FrmPrincipal.cs(117,54): error CS1525: Termo de expressão inválido 'int' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
 FrmPrincipal.cs(117,65): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(117,65): error CS1525: Termo de expressão inválido ',' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(117,67): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(117,68): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(117,68): error CS1525: Termo de expressão inválido ')' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2028,55): error CS1525: Termo de expressão inválido 'int' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2028,61): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2028,61): error CS1525: Termo de expressão inválido ')' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2028,62): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2028,62): error CS1525: Termo de expressão inválido ')' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2028,63): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2032,13): error CS1525: Termo de expressão inválido 'else' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
  FrmPrincipal.cs(2032,17): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]

Here the file . Csproj

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{2E1B2020-4F0A-4F82-90E0-A08B8D3E0E2F}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <RootNamespace>Projeto</RootNamespace>
    <AssemblyName>Projeto</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
    <TargetFrameworkProfile />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </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>
    <Prefer32Bit>false</Prefer32Bit>
  </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>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationIcon>Icone.ico</ApplicationIcon>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="DotNetZip, Version=1.13.8.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
      <HintPath>..\packages\DotNetZip.1.13.8\lib\net40\DotNetZip.dll</HintPath>
    </Reference>
    <Reference Include="System">
      <HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll</HintPath>
    </Reference>
    <Reference Include="System.Core" />
    <Reference Include="System.ServiceProcess" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Classes\Funcoes.cs" />
    <Compile Include="FrmImagemPDV.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="FrmImagemPDV.Designer.cs">
      <DependentUpon>FrmImagemPDV.cs</DependentUpon>
    </Compile>
    <Compile Include="FrmPrincipal.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="FrmPrincipal.Designer.cs">
      <DependentUpon>FrmPrincipal.cs</DependentUpon>
    </Compile>
    <Compile Include="Classes\INIFile.cs" />
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <EmbeddedResource Include="FrmImagemPDV.resx">
      <DependentUpon>FrmImagemPDV.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="FrmPrincipal.resx">
      <DependentUpon>FrmPrincipal.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <SubType>Designer</SubType>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <None Include="app.config" />
    <None Include="packages.config" />
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <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>
  </ItemGroup>
  <ItemGroup>
    <Content Include="Icone.ico" />
    <None Include="Img\Lupa.png" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

1 answer

0

Then, about msbuild, you can compare the parameters that you build with Visual Studio. Example:

/t:TestTarget
/p:VisualStudioVersion=12.0
/p:Configuration=Release
/p:Platform="Any CPU"
/p:DeployOnBuild=True
/p:DeployTarget=Test
/p:MsDeployServiceUrl=https://myserver:8172/MsDeploy.axd
/p:AllowUntrustedCertificate=True
  • It may also be the order that the projects (.csproj) are compiled in Visual Studio. This order matters when compiling in msbuild, because, if it does not have the binary dependent, it breaks the build.

  • Also check, if any, nuget package departments.

  • Another thing to do is delete the source folder to be compiled and create them again.

  • Thank you very much for the answer, I put the file . csproj in question, I do not know if this wrong.

  • You need to compare the build parameters of Visual Studio with Msbuild.

  • Got it, where do I find this Msbuild file ? if you can give me an example

  • Msbuild is a. net framework command used for compilation. For the compilation to be carried out successfully, you pass some parameters through commands or a file. I recommend reading: link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.