TheSwamp
Code Red => .NET => Topic started by: Andrey Bushman on April 06, 2015, 08:35:34 AM
-
AutoCAD version changes working directory, as I see... AutoCAD 2009-2015 don't do this.
My BAT and SCR files use relative paths into own code, therefore now (in AutoCAD 2016) they can't find necessary resources: scr, arg and dwg files, because working directory now is not the same where BAT-file is located.
I can't use absolute paths because often I use remote machines (i.e. the output paths are not the local directories). If I try to calculate a full path, then it will have somethin like that: \\CompName\DirName\etc. I can't write such paths into my BAT abd SCR files, because they are located on the remote machine and don't know such paths.
For example, it works fine for AutoCAD 2015:
call "C:\Program Files\Autodesk\AutoCAD 2015\accoreconsole.exe" /s "..\NUnit\startup-2015.scr" /p "..\NUnit\acad_2015_and_newer_NUnit_testing_profile.arg"
But for AutoCAD 2016 it doesn't work:
call "C:\Program Files\Autodesk\AutoCAD 2016\accoreconsole.exe" /s "..\NUnit\startup-2016.scr" /p "..\NUnit\acad_2015_and_newer_NUnit_testing_profile.arg"
AutoCAD 2016 output:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\developer>cd C:\public\Debug\extensions\acad-extensions\ExtensionSample
.UnitTests\run-tests
C:\public\Debug\extensions\acad-extensions\ExtensionSample.UnitTests\run-tests>r
un-tests-in-autocad-2016-NUnit.bat
C:\public\Debug\extensions\acad-extensions\ExtensionSample.UnitTests\run-tests>c
all "C:\Program Files\Autodesk\AutoCAD 2016\accoreconsole.exe" /s "..\NUnit\star
tup-2016.scr" /p "..\NUnit\acad_2015_and_newer_NUnit_testing_profile.arg"
Redirect stdout (file: C:\Users\DEVELO~1\AppData\Local\Temp\accc8722).
AutoCAD Core Engine Console - Copyright Autodesk, Inc 2009-2013.
Regenerating model.
Command:
Command:
"startup-2016.scr": Can't find file.
Command:
Command: _quit
Command:
C:\public\Debug\extensions\acad-extensions\ExtensionSample.UnitTests\run-tests>
Thus my unit tests work fine for AutoCAD 2009-2015, but don't work for AutoCAD 2016.
I can get current directory of the BAT file: %~dp0, but what about the SCR-file (its code loads a managed DLL with the unit tests)? My BAT and SCR files are generated by msbuild.
Anybody has an idea for fixing of this?
-
Hm... I found a decision: SCR file must to be genereted by a BAT file, instead of msbuild (as I did it earlier). At this case it can write absolute paths for SCR file commands.
-
Andrey thanks for this.
I copied "call "C:\Program Files\Autodesk\AutoCAD 2016\accoreconsole.exe" /s "..\NUnit\startup-2016.scr" /p "..\NUnit\acad_2015_and_newer_NUnit_testing_profile.arg" (adjusted it for me) and saved it as a .bat file. It now says "Invalid filename" , is there something else I need?
-
You are to use absolute paths instead of relative ones, as I wrote in my previous message. Thus you are to use %~dp0 in your BAT files, i.e. "%~dp0..\NUnit\startup-2015.scr" instead of "..\NUnit\startup-2015.scr"
-
Hi,
Did you try setting the LEGACYCODESEARCH (http://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-1E582989-79A5-4B88-A9C2-8826E3FF9430-htm.html) sysvar to 1 ?
-
Thanks, unfortunately I have never made a bat file before
call "C:\Program Files\Autodesk\AutoCAD 2016\accoreconsole.exe" /s "C:\Users\me\Documents\Visual Studio 2012\Projects\GetThangs15.scr"
Above is the full path. So is this all I need? I put it in notepad and saved it as .bat
this is my .cproj.user
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\Autodesk\AutoCAD 2015\acad.exe</StartProgram>
<StartWorkingDirectory>C:\Users\me\Documents\Visual Studio 2012\Projects\</StartWorkingDirectory>
<StartArguments>/p "Lex2015" /nologo /b "C:\Users\bwalmsley\Documents\Visual Studio 2012\Projects\GetThangs15.scr"</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<StartWorkingDirectory>C:\Users\me\Documents\Visual Studio 2012\Projects\</StartWorkingDirectory>
<StartArguments>/p "Lex2016" /nologo /b "C:\Users\me\Documents\Visual Studio 2012\Projects\5GetThangs15.scr"</StartArguments>
</PropertyGroup>
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
-
MCI Gile, I've been pulling my hair out. Tx
-
Bryco, I don't understand your last message. Is your problem solved?
This is a sample of my BAT file:
echo _NETLOAD "%~dp0..\NUnit\ant_ut.R20.1.dll" _QUIT Y > "%~dp0..\NUnit\startup-2016.scr"
call "C:\Program Files\Autodesk\AutoCAD 2016\acad.exe" /b "%~dp0..\NUnit\startup-2016.scr" /p "%~dp0..\NUnit\acad_2015_and_newer_NUnit_testing_profile.arg" /nologo
IF "%1" == "" call "%~dp0..\NUnit\NUnitOrange.exe" "%~dp0..\reports\xml-reports\ant_ut.R20.1-NUnit.xml" "%~dp0..\reports\ant_ut.R20.1.html"
This BAT file was generated by msbuild.exe according the settings of my CSPROJ file.
this is my .cproj.user
I don't use such files for C# projects of my AutoCAD .NET extensions.
-
Tx Andrey, it is solved but tx for the bat file info, I will try it